← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Meta SWE coding round with two problems back to back. One was pretty standard merge stuff, the other was a classic BFS/backtracking problem that I've seen before but still had to think through carefully under pressure.

Questions Asked (2)

Q1

Given three sorted integer arrays, merge them into a single sorted array with all duplicates removed.

Algorithms & Data Structures
Author's notes

Pretty approachable if you've done merge sort variants before.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a min-heap to perform a k-way merge across the three arrays, tracking the last added value to skip duplicates. Alternatively, use three pointers to merge sequentially while deduplicating. Discuss time and space complexity and handle edge cases like empty arrays.

Pro tip: Clarify whether the input arrays can contain duplicates and whether the output must be sorted in ascending order. Also, mention that if the arrays are very large, a heap-based approach is more efficient than merging two at a time.

1. Clarify requirements and constraints

Ask about input sizes, whether arrays can be empty, if duplicates exist within each array, and if the output should be a new array or in-place. Confirm the expected time/space complexity.

2. Choose an approach

Decide between a heap-based k-way merge (O(N log k) time) or iterative two-array merge (O(N * k) time). Explain the trade-offs and pick the most efficient for the given constraints.

3. Outline the algorithm

For heap approach: initialize a min-heap with the first element of each non-empty array, along with array index and element index. Repeatedly extract the minimum, add to result if different from last added, and push the next element from the same array. For pointer approach: merge arrays one by one while skipping duplicates.

4. Handle duplicates and edge cases

During merge, compare the current element with the last added element to skip duplicates. Handle empty arrays by ignoring them in the heap or pointer initialization. Ensure the result is sorted and contains no duplicates.

5. Analyze complexity and test

State time complexity: O(N log k) for heap, where N is total elements and k=3; space O(N) for output plus O(k) for heap. Walk through a small example to verify correctness, including duplicates and empty arrays.

Key Points to Mention

  • Time and space complexity analysis for the chosen approach
  • Handling duplicates by comparing with the last added element
  • Edge cases: empty arrays, arrays with all duplicates, single-element arrays
  • Use of a min-heap for efficient k-way merge (k=3)
  • Alternative approach: merging two arrays at a time and then merging with the third
  • Stability and whether the output should be a new array or modify input

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given a string with letters and parentheses, remove the minimum number of parentheses to make it valid, and return all distinct valid results.

Algorithms & Data Structures
Author's notes

This one took me a minute to even figure out the right approach.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use BFS level-by-level to remove one parenthesis at a time, checking validity at each level. Stop at the first level where valid strings are found, as that represents the minimum removals. Use a set to avoid duplicates and return all valid strings at that level.

Pro tip: Mention that BFS guarantees minimum removals because it explores all strings with k removals before k+1 removals. Also, deduplicate at each level to avoid exponential blowup, and note that the maximum removals is n, so the algorithm is O(2^n) in the worst case but often much faster.

1. Clarify and define validity

Confirm that a valid string has balanced parentheses and no unmatched closing before opening. Define a helper function to check validity in O(n) time.

2. BFS with level-order traversal

Start with the original string in a queue. For each level, process all strings, and if any is valid, return all valid strings at that level. Otherwise, generate next level by removing one parenthesis from each string.

3. Deduplicate to avoid redundant work

Use a set to store strings at each level, ensuring no duplicates are processed. This is crucial for efficiency and to return distinct results.

4. Generate next level candidates

For each string, iterate through characters; if a character is '(' or ')', create a new string by removing it. Add to next level set.

5. Return results and analyze complexity

When valid strings are found at a level, return them as a list. Discuss time and space complexity: worst-case O(2^n) but often better due to pruning.

Key Points to Mention

  • BFS ensures minimum removals by exploring all strings with k removals before k+1.
  • Validity check: balance counter, ensuring it never goes negative and ends at zero.
  • Use a set for deduplication at each level to avoid processing duplicates.
  • Stop at the first level where valid strings are found.
  • Time complexity: O(2^n) worst-case, but pruning and deduplication improve practical performance.
  • Space complexity: O(2^n) for the queue and sets in worst-case.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.