Facebook | Phone | Count occurrences of a number in sorted array & Find the Celebrity

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-05-12Added By Anonymous
Source: Link

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

Original Post Content:

I was asking following two questions

Question 1:
Find the number of occurrences of an element in a sorted array
I told in linear search its very easy and told it can be done in binary search as well.
Wrote the binary search and to expand on both sides of the array to get the count/

Question 2:
https://leetcode.com/problems/find-the-celebrity/ (premium)
Came with O(n^2) design but the interviewer asked O(n). I had never solved that problem before and found it tough to come with the solution in just 15 mins.

A week later I mailed the Recruiter for feedback and got back a standard rejection mail.

Comments