Given number M and N intervals in the form [a, b] (inclusive) where for every interval -M <= a <= b <= M , create a program that returns a point where the maximum number of intervals overlap.
Example:
M: 10
N: 4
Intervals:
[-3, 5]
[0, 2]
[8, 10]
[6, 7]
A correct answer would be either 0 , 1 or 2 since those points are found where 2 intervals overlap and 2 is the maximum number of overlapping intervals.
First one is easy level, valid palindrome question https://leetcode.com/problems/valid-palindrome-ii/
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
I solved this question in 17 mins. They do not let you run the code so it’s important to test your code by hand line by line and talk about Big(O).
Second questions was (medium) vertical order traversal of a binary tree: https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/
I was very close to finish but there was not enough time left. I did bfs traversal on a tree and hash map to store each node.
You should take 20-30 minutes to finish implementing efficient solution to the problem.
Then after 3 days, I got rejected after I contacted my recruiter about the result. My advice to anyone interviewing with Facebook:
a) you either get 1 easy and 1 medium level question. In such cases, you should finish coding easy level question in max 15 mins and medium level in 20-30 mins.
b) or they might ask you 1 Hard question which you should solve in 35-45 mins.
c) or you might get 2 medium problems. 20-25 mins each.