← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round, 40 minutes, two problems back to back. No running code, just talking through logic and edge cases. Pretty standard stuff but the second problem tripped me up a bit.

Questions Asked (2)

Q1

Given a string of lowercase letters, determine whether it can become a palindrome by deleting at most one character.

Algorithms & Data Structures
Author's notes

Two-pointer from both ends, and when you hit a mismatch you try skipping one side or the other.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a two-pointer technique to compare characters from both ends, and when a mismatch occurs, check if skipping either the left or right character results in a palindrome. This yields an O(n) time and O(1) space solution, which is optimal.

Pro tip: Clarify that 'at most one deletion' includes zero deletions, and mention that the two-pointer approach is optimal because it avoids unnecessary checks and handles all cases efficiently.

1. Clarify the problem

Confirm that the string contains only lowercase letters and that we can delete at most one character. Also, note that an empty string or a single-character string is already a palindrome.

2. Initialize two pointers

Set left pointer at the start and right pointer at the end of the string. Compare characters while left < right.

3. Handle mismatch

When characters at left and right don't match, check if the substring skipping the left character or skipping the right character is a palindrome. If either is, return true.

4. Return result

If no mismatches are found, the string is already a palindrome, so return true. If a mismatch occurs and neither skip works, return false.

Key Points to Mention

  • Time complexity: O(n) because each character is visited at most twice.
  • Space complexity: O(1) as we only use pointers and no extra data structures.
  • Edge cases: empty string, single character, already palindrome, and strings requiring deletion at the beginning or end.
  • The two-pointer technique efficiently narrows down the problem to checking two substrings.
  • The solution is optimal and commonly expected in interviews.
  • Avoid using recursion or extra space to keep it efficient.

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

Q2

Given a number of courses and a list of prerequisite pairs, determine whether it is possible to complete all courses without a circular dependency.

Algorithms & Data Structures
Author's notes

Cycle detection in a directed graph.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses and prerequisites as a directed graph where edges represent prerequisite relationships. Then determine if the graph is acyclic by performing a topological sort (using Kahn's algorithm or DFS) and checking if all courses can be processed. If a cycle exists, it's impossible to complete all courses.

Pro tip: Clarify edge direction upfront (e.g., prerequisite -> course) to avoid confusion, and mention that Kahn's algorithm naturally detects cycles by counting processed nodes. Also, discuss how you'd handle large inputs by using iterative DFS to avoid recursion depth issues.

1. Clarify and Model the Problem

Confirm the input format and edge direction (e.g., pair [a, b] means b depends on a). Represent courses as nodes and prerequisites as directed edges in a graph.

2. Choose Cycle Detection Strategy

Decide between Kahn's algorithm (BFS-based topological sort) or DFS with recursion stack. Explain why one might be preferred (e.g., Kahn's is iterative and easy to reason about).

3. Implement the Algorithm

For Kahn's: compute in-degrees, enqueue nodes with in-degree 0, process and decrement neighbors, count processed nodes. For DFS: track visited and recursion stack to detect back edges.

4. Analyze Complexity and Edge Cases

State time and space complexity (O(V+E)). Discuss edge cases: no prerequisites, disconnected components, self-loops, and duplicate edges.

5. Conclude and Verify

If all nodes are processed (Kahn's) or no cycle found (DFS), return true; otherwise false. Optionally, walk through a small example to validate.

Key Points to Mention

  • Graph representation: adjacency list for efficiency
  • Topological sorting as the core concept
  • Kahn's algorithm (BFS) vs DFS with recursion stack
  • Cycle detection via in-degree counting or back edges
  • Time and space complexity: O(V+E) time, O(V+E) space
  • Handling edge cases: empty input, self-loops, disconnected graphs

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