LogIn
I don't have account.

My Meta (Facebook) Round 1 Interview Experience , SDE III ~ Aug 2025

DevSniper

64 Views
Role: SDE-3 (E5 level)
Format: 45 min (5 min intro, 35–38 min coding, 2–3 min wrap-up)
Platform: CoderPad on Zoom

Warm-up / Intro

We started with light conversation — my background, recent project I’m proud ofand the tech stacks I’ve worked with in past roles. The interviewer then outlined the plan for the interview :

“We’ll do two coding problems today. Please think aloud so I can follow your thought process.”

This set a comfortable tone and clarified expectations before diving into problem-solving.

Question 1 – Interval Merging with Twist

We’re given start and end times (in minutes) for meetings. We need to find the minimum number of meeting rooms needed so that no meetings overlap.

This is a classic interval problem that can be solved using a min-heap (priority queue).

Follow-up : The follow-up allows us to shift meetings by at most k minutes earlier or later to possibly reduce overlaps.

My Thinking (Without k)

  • I recognized the classic “Meeting Rooms II” problem.
  • Sort meetings by start time.
  • Use a min-heap to track end times of ongoing meetings.
  • For each meeting
    1. If the earliest meeting in the heap ends before the current meeting starts → reuse that room (remove from heap).
    2. Otherwise, we add a new room.
  • Answer = Maximum heap size at any point.
Copy
public static int minMeetingRooms(int[][] intervals) {
        if (intervals == null || intervals.length == 0) return 0;

        // Sort by start time
        Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0]));

        // Min-heap to track earliest ending meeting
        PriorityQueue<Integer> minHeap = new PriorityQueue<>();

        int maxRooms = 0;

        for (int[] interval : intervals) {
            // Free a room if the earliest meeting has ended
            while (!minHeap.isEmpty() && minHeap.peek() <= interval[0]) {
                minHeap.poll();
            }

            // Allocate room for the current meeting
            minHeap.offer(interval[1]);

            // Track the maximum rooms in use at any point
            maxRooms = Math.max(maxRooms, minHeap.size());
        }

        return maxRooms;
    }

My Thinking with k Minutes Shift (Flexible Scheduling)

Twist :Now we can shift a meeting’s start time earlier or later by at most k minutes to avoid overlap.

  • Sort by start time.
  • For each meeting
    1. Remove all meetings that have ended before the current one starts.
    2. If overlap exists, check if delaying the meeting start by ≤ k minutes avoids conflict.
    3. If so, reuse the same room.
  • Track maxRooms during processing (peak heap size).
Copy
public static int minMeetingRoomsWithShift(int[][] intervals, int k) {
        if (intervals == null || intervals.length == 0) return 0;

        Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0]));
        PriorityQueue<Integer> minHeap = new PriorityQueue<>();
        int maxRooms = 0;

        for (int[] interval : intervals) {
            while (!minHeap.isEmpty()) {
                int earliestEnd = minHeap.peek();

                // Case 1: Fits without shift
                if (earliestEnd <= interval[0]) {
                    minHeap.poll();
                }
                // Case 2: Can delay start to avoid overlap
                else if (earliestEnd - interval[0] <= k && earliestEnd > interval[0]) {
                    interval[0] = earliestEnd; // shift to start right after earliest meeting
                    minHeap.poll();
                }
                // Case 3: Cannot fit in current earliest room
                else {
                    break;
                }
            }

            // Allocate (or reuse) room
            minHeap.offer(interval[1]);
            maxRooms = Math.max(maxRooms, minHeap.size());
        }

        return maxRooms;
    }
Complexities
  • Time: O(N log N) (sorting + heap ops)
  • Space: O(N) (heap storage)

Question 2 – String Transformation Check

Given two strings s and t, check if you can transform s into t by deleting some characters and reordering remaining ones.

Follow-up : What if reordering is not allowed? What’s the complexity change?

My Thinking for case Reordering Allowed

Idea : If we can reorder, the problem reduces to checking whether t is a subset of s’s characters with enough frequency.

Steps
  • Count frequency of characters in s and t.
  • For every char in t, check if count_s[char] >= count_t[char].
  • If all pass → transformation is possible.
Complexity
  • Time: O(|s| + |t|) (counting)
  • Space: O(1) for fixed alphabet (e.g., lowercase letters).

Java Implementation

Copy
public static boolean canTransformWithReorder(String s, String t) {
        int[] countS = new int[256];
        int[] countT = new int[256];

        for (char c : s.toCharArray()) countS[c]++;
        for (char c : t.toCharArray()) countT[c]++;

        for (int i = 0; i < 256; i++) {
            if (countT[i] > countS[i]) return false;
        }
        return true;
    }

Follow up : Reordering NOT Allowed

Idea : Now we must keep order → This becomes subsequence check. t must be a subsequence of s.

Steps
  • Use two pointers: i for s, j for t.
  • Move through s
    1. If s[i] == t[j], move both pointers.
    2. Else, move only i.
  • If j reaches length of t, it’s possible.
Complexities
  • Time: O(|s|) (one pass)
  • Space: O(1).

Java Implementation

Copy
public static boolean canTransformWithoutReorder(String s, String t) {
        int i = 0, j = 0;
        while (i < s.length() && j < t.length()) {
            if (s.charAt(i) == t.charAt(j)) {
                j++;
            }
            i++;
        }
        return j == t.length();
    }

Observation

  • Meta interviewers like to layer complexity — starting simple, then introducing constraints to see your adaptability.
  • They appreciate it when you preemptively analyze complexity without being asked.

My Key Takeaways

  • Think out loud — narrate every assumption, variable name and step.
  • Handle edge cases early — I checked for empty arrays and strings before diving into logic.
  • Trade-offs matter — even for small DS/Algo problems, they want to see why you choose one approach over another.
  • Follow-ups are the real test — solving the base case is expected, but handling constraints under time pressure is where SDE-3 candidates are evaluated.