Feature #3: Meeting Activity

Implementing the "Meeting Activity" feature for our "Zoom" project.

Description

A large number of employees across the globe had to switch to working from home during the pandemic as their companies shut offices down. In this situation, Zoom is a popular collaboration tool, and the number of people using Zoom to work from home is increasing daily. Working from home has caused a lot of stress for employees and has made team building challenging for the employer. Employers have introduced several remote activities that help people relax and get to know each other. Zoom wants to play its part in this by providing fun team activities for online meetings. Zoom has decided to introduce mini games that can be played during meetings. One game they are making is a guessing game that is played on a timer. In this game, the user will be shown an image of stairs with n steps numbered from 0 to n - 1. Each step on the stair also has a number written on it. The player’s answer will be the minimum number of steps that a sprite at the bottom of the stairs needs to take to get to the top.

Your task is to implement a function that can find the correct answer given an array, k, containing the values written on the steps of the stairs. The rules of the game are the following:

  • The sprite can jump from step i to step i + 1, where i + 1 < n.
  • The sprite can jump from step i to step i - 1, where i - 1 >= 0.
  • The sprite can jump from step i to step j, where k[i] == k[j] and i != j.

For example, consider the following mini-game and its solution:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.