← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round with two LeetCode problems back to back. Nothing too wild but the UTF-8 one is sneakier than it looks.

Questions Asked (2)

Q1

Implement a function to validate whether a given list of integers represents a valid UTF-8 encoding.

Algorithms & Data Structures
Author's notes

Looked straightforward at first glance and then I started second-guessing myself on the bit manipulation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the input is a list of integers, each representing a byte (0-255). Then, iterate through the list, using a state machine or bit manipulation to validate the UTF-8 encoding rules: single-byte characters start with 0, multi-byte characters start with a sequence of 1s followed by 0, and continuation bytes start with 10. Keep track of the number of expected continuation bytes and ensure they match.

Pro tip: Mention that you would handle edge cases like empty list, invalid start bytes (e.g., 0xFF), and incomplete sequences. Also, discuss the trade-off between using a state machine and bit manipulation for clarity and performance.

1. Clarify input and constraints

Confirm that the list contains integers in the range 0-255, each representing a byte. Ask if the list can be empty or if there are any constraints on length.

2. Define UTF-8 encoding rules

Explain the rules: 1-byte: 0xxxxxxx; 2-byte: 110xxxxx 10xxxxxx; 3-byte: 1110xxxx 10xxxxxx 10xxxxxx; 4-byte: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. Continuation bytes always start with 10.

3. Design validation algorithm

Iterate through the list. For each byte, determine if it's a start byte or continuation byte. If start byte, compute the number of expected continuation bytes and check that the following bytes are valid continuation bytes. Use bit masks to extract relevant bits.

4. Handle edge cases and errors

Check for invalid start bytes (e.g., 0xFF, 0xFE), incomplete sequences at the end, and unexpected continuation bytes. Return false immediately upon any violation.

5. Analyze complexity and test

State that the algorithm runs in O(n) time and O(1) space. Walk through a few test cases: valid multi-byte sequences, invalid sequences, empty list.

Key Points to Mention

  • UTF-8 encoding rules and byte patterns
  • Bitwise operations to check leading bits (e.g., byte & 0x80, byte & 0xE0, etc.)
  • State machine or counter approach to track expected continuation bytes
  • Edge cases: empty list, invalid start bytes, incomplete sequences, overlong encodings (if relevant)
  • Time and space complexity: O(n) time, O(1) space
  • Handling of integers outside 0-255 (if input not guaranteed)

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

Q2

Find the shortest path from the top-left to the bottom-right of a binary matrix, moving through cells with value 0 in 8 directions.

Algorithms & Data Structures
Author's notes

Classic BFS, felt more comfortable here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the problem is a shortest path on an unweighted graph where each 0-cell is a node and edges connect to 8 neighbors. Then choose BFS for optimality, or A* with Chebyshev distance heuristic for efficiency, and discuss trade-offs.

Pro tip: Mention that BFS is optimal for unweighted graphs, but A* with Chebyshev distance can be more efficient in practice; also handle edge cases like start/end being 1 or out of bounds.

1. Clarify problem and constraints

Confirm matrix dimensions, movement rules (8 directions), and that only 0-cells are traversable. Ask about edge cases: start/end blocked, empty matrix, large size.

2. Model as graph and choose algorithm

Treat each 0-cell as a node with edges to its 8 neighbors. For unweighted shortest path, BFS guarantees optimality; A* with Chebyshev distance can be faster but requires a consistent heuristic.

3. Outline BFS implementation

Use a queue for BFS, a 2D array for distances (or visited set), and iterate through 8 directions. Return distance when reaching bottom-right, or -1 if unreachable.

4. Analyze complexity and optimizations

Time O(R*C) since each cell visited once; space O(R*C) for queue/visited. Mention bidirectional BFS or A* for potential speedup on large grids.

5. Test with examples and edge cases

Walk through a small matrix, test blocked start/end, single cell, and unreachable cases. Verify 8-direction movement correctly includes diagonals.

Key Points to Mention

  • BFS is optimal for unweighted graphs; A* with Chebyshev distance is a valid alternative.
  • 8-directional movement means each cell has up to 8 neighbors; use direction arrays.
  • Handle edge cases: start or end is 1, matrix empty, or no path exists.
  • Time and space complexity: O(R*C) for BFS, O(R*C) space for visited/queue.
  • Use a distance matrix or visited set to avoid revisiting cells.
  • Consider bidirectional BFS or A* for performance on large matrices.

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