Facebook phone screen - June 2021

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-06-21Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: 2021

Original Post Content:

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 approach of storing the indexes for max element in a list and then retrieving 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.

Comments