← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Meta software engineering interview with two algorithmic problems back to back. Both were coding-focused with complexity analysis required, which I half-expected but still felt the pressure on the second one.

Questions Asked (2)

Q1

Given an array of integers in [0, 255] representing bytes, determine whether the sequence encodes valid characters under a variable-length encoding scheme. Single-byte characters start with bit 0, multi-byte characters use a specific prefix pattern for the first byte and 10xxxxxx for continuation bytes, and the sequence must not end mid-character. Return true or false and explain your time and space complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one looked like a bit manipulation problem but it's really just careful state tracking.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the encoding rules (e.g., UTF-8) and then validate the byte sequence by scanning left to right, checking the leading bits of each byte to determine the character length and ensuring continuation bytes follow. Track the expected number of continuation bytes and verify the sequence ends exactly at a character boundary.

Pro tip: Mention that you can validate in a single pass without extra space, and discuss edge cases like empty input, truncated sequences, and invalid prefixes to demonstrate thoroughness.

1. Clarify encoding rules

Confirm the specific prefix patterns for 1-, 2-, 3-, and 4-byte characters (e.g., UTF-8) and that continuation bytes must be 10xxxxxx.

2. Design validation algorithm

Iterate through the array, using the first byte to determine the expected number of continuation bytes, then verify each subsequent byte has the 10 prefix.

3. Handle edge cases

Check for empty input, sequences ending mid-character, and invalid leading bytes (e.g., 10xxxxxx as first byte).

4. Analyze complexity

State that time complexity is O(n) since each byte is visited once, and space complexity is O(1) as only a few variables are used.

5. Test with examples

Walk through valid and invalid sequences to demonstrate correctness and catch off-by-one errors.

Key Points to Mention

  • Bitwise operations to check prefixes (e.g., byte & 0x80, byte & 0xE0, byte & 0xF0, byte & 0xF8)
  • Single-pass validation with constant extra space
  • Handling of empty input and sequences that end mid-character
  • Time complexity O(n) and space complexity O(1)
  • Edge cases: invalid leading bytes, insufficient continuation bytes, extra continuation bytes
  • Comparison to standard UTF-8 validation and potential variations in encoding schemes

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

Q2

Given an n×n binary grid where 0 means open and 1 means blocked, find the shortest path from the top-left to the bottom-right cell using 8-directional movement. Count both the start and end cells in the path length, and return -1 if no path exists. Discuss your algorithm and its complexity.

Algorithms & Data Structures
Author's notes

BFS, pretty standard.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use BFS to find the shortest path in an unweighted grid with 8-directional movement. Initialize a queue with the start cell, track visited cells, and count steps including both start and end. If the end is reached, return the step count; otherwise, return -1.

Pro tip: Clarify that BFS is optimal for unweighted graphs and mention that 8-directional movement can be handled by iterating over 8 offsets. Also, discuss edge cases like start or end being blocked.

1. Understand the problem

Restate the problem: find shortest path in n×n binary grid with 8-directional moves, count start and end cells, return -1 if no path. Confirm assumptions like start and end are open.

2. Choose algorithm

Select BFS because it finds shortest path in unweighted graphs. Explain why DFS or Dijkstra is not optimal here.

3. Implement BFS

Use a queue for BFS, a visited matrix to avoid revisiting, and track distance. For each cell, explore 8 neighbors, enqueue if valid and unvisited.

4. Handle edge cases

Check if start or end is blocked; if so, return -1. Also handle n=1 case where start equals end.

5. Analyze complexity

Time complexity O(n^2) since each cell visited once, space O(n^2) for queue and visited matrix.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs.
  • 8-directional movement: use offsets like (-1,-1), (-1,0), ..., (1,1).
  • Path length includes both start and end cells, so initial distance is 1.
  • Visited matrix prevents cycles and redundant work.
  • Edge cases: start or end blocked, n=1, no path.
  • Time and space complexity: O(n^2) each.

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