Facebook | Screening Interview | US | Accepted
Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: US
Year: unknown
Original Post Content:
Interviewer explained a bit about the Technical Screening round, like how he wants to structure the interview:
1. Introduction and a little bit about his experience ~ 5 min
2. 2 coding questions which need finished/complete code ~ 35 min
3. Questions and feedback ~ 5 min
Q1: ~ approach: 4 min ~ coding: 5 min ~ complexity: 1-2 min
Given an array of integers, return the position of the maximum element. If the maximum element occurs multiple times, use a random number generator to choose one of the positions uniformly at random.
I asked a few questions:
1. What to return when the array is empty?
2. Does frequency for a repeating max number determine uniformity of position's randomness?
I walked through how I wanted to solve it.
Sol 1: I gave a simple map-based solution which holds element and position; he was not happy.
Sol 2: linear time and no extra space.
Q2: ~ approach: 5 min ~ coding: 15 min ~ complexity: 5 min
You are given N integer intervals [a_i, b_i] on the real axis, and the absolute value of the coordinates is bounded by M. Determine a point that belongs to the maximum number of intervals. Point x belongs to the interval [a, b] if a <= x <= b.
This one was confusing, so I asked a few "dumb" questions:
1. Is this on the x-axis and there is no y-axis? --> just x axis
2. Can intervals have negative values? --> Yes
3. What if the interval List is empty, return -1? --> Yes
I read the question again, explained what I understood.
Sol 1: sort intervals and then look for point x that is present in most of the intervals; he was not happy.
Sol 2: Instead of sorting, determine the start and end of all of the intervals combined, then use a PriorityQueue which is sorted based on the count for point x seen on intervals. He asked me to implement it.
Walked through run time and space complexity. Everything was okay till I said queue.poll() will take O(1) time instead of O(log(M)).
Feedback came positive, moving to Virtual Onsite, next week.