In December 2020 I applied for "Software Engineer, University Grad" position at Facebook (now Meta).
I was contacted by the recruiter in a few days to schedule the Screening Interview.
1) Screening Interview:
The interview was of 45 minutes.
Following questions were asked:
In both the cases, I was asked to dry run my code and also analyze the space and time complexity.
Virtual Onsite Interview:
1) Behavioral Round:
Following questions were asked by the interviewer:
-Most challenging project
-Time when I received a constructive feedback
-A person who was difficult to deal with in a professional setting
-If I had any arguments with fellow team member
2) Coding Round 1:
The interview was of 45 minutes. (Last 5 minutes are reserved for the candidates to ask any questions, so we have only 40 minutes to solve two questions)
Following questions were asked:
Given a 2D binary matrix with 1s and 0s in the cell, you have to find a path from upper left corner to bottom right corner. You can traverse the 0s but 1s are blocking cells. And print the path if it exists. It is a variation of the following question on leetcode:
https://leetcode.com/problems/shortest-path-in-binary-matrix/
I first suggested a depth first solution and the interviewer asked me its space complexity. I answered (nrows * ncols). However, the correct answer was (nrows + ncols). The interviewer also asked if there is any other solution and I suggested a breadth first search approach. Then (s)he asked which one was better and why. (S)he suggested me to code the BFS solution and then asked me to write down as many test cases as possible. Be sure to handle cases such as:
-Grid exists but has no rows or columns
-Grid does not exist, check if its null
-The first cell has a value 1
-The last cell has a value 1
BST Iterator:
https://leetcode.com/problems/binary-search-tree-iterator/
The interviewer asked if there was anything in the code that can be improved. I wondered for a minute but then (s)he changed the topic.
3) Coding Round 2:
Minimum Remove to Make Valid Parentheses
https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/
After explaining and coding the solution, the following questions were asked"
-Time and Space Complexity
-If there was any way to reduce the space complexity to O(1).
-What if strings were mutable in java, then would it be possible to reduce the space complexity to O(1)?
Subarray sum equals k:
https://leetcode.com/problems/subarray-sum-equals-k/solution/
Follow up questions:
-Time and Space Complexity
-If there is any way to optimize the code if only positive values are included. (Sliding Window)
Few notes which might help:
PS: I received the offer! Thank you!