📌 Facebook | E5 | Bay Area | Phone Screen
Anonymous User
13643

Note: Don't forget to upvote if you find this post helpful. Also, let me know in the comments if you have any questions. I will try to answer them. Thanks for reading!

Hi Everyone, in my last Leetcode post, I shared my Facebook E5 Virtual Onsite Experience - https://leetcode.com/discuss/interview-experience/1096480/Facebook-Virtual-Onsite-or-E5-or-Bay-Area

Some of you asked in the comments about my phone screen experience. So, here are the details.

The interview was of 45 minutes. We both introduced each other in the beginning for about 3-5 minutes. The interviewer then said that we will mainly focus on the questions in the remaining time, and he will leave about 5 minutes in the end to answer any questions I have.

The first question was Add Binary. Since I had done this question beforehand, I directly explained to him the optimal approach, which had a time complexity of O(max(l1, l2)). He was fine with the algorithm, and then I quickly coded the solution in Java. I explained and walk-through the code with a few examples. He was happy with the solution and moved to the next question. This question with all the discussions was completed within 10-15 minutes.

/**
 * Time Complexity: O(max(l1, l2))
 * Space Complexity: O(max(l1, l2))
 * l1 = Length of string A, l2 = Length of string B.
 */
public String addBinary(String a, String b) {
    if (a == null && b == null) {
        return "0";
    }

    StringBuilder result = new StringBuilder();

    int i = a.length() - 1;
    int j = b.length() - 1;
    int carry = 0;

    while (i >= 0 || j >= 0) {
        int sum = carry;
        if (i >= 0) {
            sum += a.charAt(i) - '0';
            i--;
        }
        if (j >= 0) {
            sum += b.charAt(j) - '0';
            j--;
        }
        result.append(sum % 2);
        carry = sum / 2;
    }

    if (carry == 1) {
        result.append('1');
    }

    return result.reverse().toString();
}

The second question was Merge Intervals. Here, I also explained the optimal approach, which had a time complexity of O(NlogN). Once he was happy with the algorithm, I coded the solution in Java and walked through the code with a few examples. I spent around 20-25 minutes on this question.

/**
 * Time Complexity O(N log N)
 * Space Complexity: O(N) (Including the List<int[]> result)
 * N = Length of input array.
 */
public int[][] merge(int[][] intervals) {
    if (intervals == null || intervals.length <= 1) {
        return intervals;
    }

    Arrays.sort(intervals, (a, b) -> (a[0] - b[0]));

    List<int[]> result = new ArrayList<>();
    int start = intervals[0][0];
    int end = intervals[0][1];

    for (int i = 1; i < intervals.length; i++) {
        if (intervals[i][0] <= end) {
            end = Math.max(end, intervals[i][1]);
        } else {
            result.add(new int[] { start, end });
            start = intervals[i][0];
            end = intervals[i][1];
        }
    }

    result.add(new int[] { start, end });
    return result.toArray(new int[result.size()][2]);
}

In the end, a few minutes were remaining. I asked him two questions related to the work he was currently doing at FB.

Note: I think knowing the questions beforehand helped me a lot to finish both of them within 45 minutes with optimal solutions. So, one advice to everyone who is currently preparing is to complete as many Leetcode questions (recent FB tagged) as possible as most questions do get repeated in the interview.

Update on the results: I got a call from the recruiter, and she told me that I have received positive feedback from the hiring committee. Now, they will be moving forward with the offer. Once finalized, I will share more details on the compensation in a separate post in the Leetcode Compensation discussion forum.

Once again, thanks to the LeetCode Community for all the help and support in the last few months. It really helped a lot 🙂

Edit 1:
Offer Details: https://leetcode.com/discuss/compensation/1118731/facebook-software-engineer-e5-bay-area-offer-march-2021
Interview Preparation Strategy: https://leetcode.com/discuss/interview-experience/1129797/facebook-e5-interview-preparation-journeystrategy-offer-accepted

Comments (16)