Facebook | Call | Tecnical Question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-07-12Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

I had an interview with Facebook/Meta a while ago and one of the questions bugged me. I didn't succeed but now I'm looking to improve on where I was back then. I'm not sure what the questions "name" was, but this was it:

Given a list of city names and their corresponding populations, write a program to output a city name subject to the following constraint: the probability of the program to output a city's name is based on its population divided by the sum of all cities' population. Assume the program will be repeatedly called many times.

For example:

NY: 7MM
SF: 5MM
LA: 8MM
The probability to generate NY is 7/20, SF is 1/4.

I completely blanked and didn't do a good version. Could anyone point me to the leetcode equivalent question? Or give me some advice on this one?

Comments