Problem understanding what online assessment question was asking
Anonymous User
161

Hi so I got this problem described as below:

You have an array of players, and their respective scores. The index value of the array represents the person number, and the value at that index represents the person's score. Example:

arr = [100,50,40,30, 25]

A certain player can level up, if they're not past the threshold of K. For example, if K is 4, in the previous array, there can only be 3 people who level up.

100 is the highest score, so it is 1
50 is the second highest score, so it is 2
40 is the third highest score, so it is 3
30 is the fourth highest score, so they can level up (being at 4th place)
25 is the fifth highest score, they cannot level up, because they are past the threshold of 4 (being in 5th place)

The task was to output the number of players who could level up in total. I didn't really know where to start with this problem, is it as basic as counting the index of each player and checking if it's greater than K's value??

Any insight on how to approach this problem would be very helpful :)
Thanks (this problem was given on the hacker rank website)

Comments (0)