Anyone can solve this asked in a coding round:
N people are standing in a row. A list of height[] of N positive integer is given where ith interger represent height of ith person there is movie screen at right most position of row the ith person will be able to see if k person directly to right side of the i th person have height lesser than the height of ith person if there are less than k people to right of ith person then height of all must be lesser than that of ith person.
You need to count the number of people who will able to watch the movie
Eg
N = 4
k = 1
height = [4,3,1,2,5]
Op = 3
the 1st 2nd and 5th will able to see 3rd cant
N = 5
k = 3
height = [9,7,7,7,4]
op = 3
Const: k, n <= 10^5