From a given list of integers print the index of max number , if the max number is present multiple times, each time a different index should be printed uniformly.
Input : [5,0,2,5,4,5]
printMax() - Output: 0
printMax() - Output: 5
printMax() - Output: 3
I gave an aproach of storing the indexes for max element in a list and then retreiving them for result, the interviewer asked me to do better on the space complexity, I couldn't figure out a different way and the interviewer ended up giving a hint on working with the frequency of element. Caught the hint and coded with Math.Random and frequency of element together. Got a reject though.