← Meta Interview Insights

Meta·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Two coding problems at Meta for an MLE role. One was a compression plus dot product question, the other was a log parsing stack problem. Nothing behavioral, just back to back algorithms.

Questions Asked (2)

Q1

Design a run-length encoding scheme for integer vectors with many repeated consecutive values, then compute the dot product of two such vectors using only their compressed representations, without expanding them back out.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The compression part was fine, I'd seen RLE before.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining a run-length encoding (RLE) representation for integer vectors, then design an algorithm to compute the dot product directly on the compressed runs by iterating through both RLE sequences and handling overlapping segments. Analyze the time and space complexity, and discuss trade-offs such as compression ratio and edge cases.

Pro tip: Emphasize that the dot product can be computed in O(n + m) time where n and m are the number of runs, which is optimal, and mention that this approach is particularly beneficial for sparse or highly repetitive data common in ML embeddings.

1. Define RLE representation

Propose a data structure for RLE, e.g., a list of (value, count) pairs, and explain how it compresses consecutive repeated integers.

2. Design dot product algorithm

Outline an algorithm that traverses both RLE sequences simultaneously, maintaining pointers and remaining counts, and accumulates the product of overlapping values.

3. Handle edge cases and alignment

Discuss how to handle runs of different lengths, ensure correct alignment, and manage cases where one vector is longer or runs do not overlap.

4. Analyze complexity and trade-offs

Compute time and space complexity, compare with expanding vectors, and discuss scenarios where RLE is advantageous or not.

5. Consider optimizations and extensions

Mention potential optimizations like early termination, parallelization, or adapting to sparse vectors, and relate to ML applications.

Key Points to Mention

  • RLE data structure: list of (value, count) pairs
  • Two-pointer technique for simultaneous traversal
  • Time complexity O(n + m) where n, m are number of runs
  • Space complexity O(1) extra beyond input
  • Handling of zero values and their impact on dot product
  • Trade-offs: compression ratio vs. computational overhead

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

Q2

Given a list of function start and end log entries with timestamps on a single-threaded CPU, compute the exclusive execution time for each function, accounting for nested calls.

Algorithms & Data Structures
Author's notes

Stack problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a stack to track active function calls, computing exclusive time by subtracting nested durations from the total elapsed time. When a function starts, push its ID and start time; when it ends, pop and add the exclusive time, then update the parent's start time to account for the child's duration.

Pro tip: Clarify that timestamps are inclusive and that the CPU is single-threaded, so no overlapping calls occur. Also, mention that you'll handle edge cases like multiple top-level calls and deeply nested calls.

1. Clarify assumptions and edge cases

Confirm that logs are well-formed, timestamps are integers, and the CPU is single-threaded. Discuss handling of nested calls and multiple top-level calls.

2. Choose data structures

Use a stack to track active function calls and a dictionary or array to accumulate exclusive times per function ID.

3. Process logs sequentially

Iterate through logs: on 'start', push (id, timestamp); on 'end', pop, compute exclusive time as (end - start + 1) minus time spent in nested calls, and update parent's start time.

4. Compute exclusive time correctly

When a function ends, its exclusive time is the total duration from its start to end minus the sum of exclusive times of all nested calls. Adjust the parent's start time to the current end time + 1 to avoid double-counting.

5. Analyze complexity and test

Time complexity is O(n) for n logs, space O(n) for stack and output. Walk through a simple example and a nested example to verify correctness.

Key Points to Mention

  • Stack-based approach to handle nested calls
  • Inclusive timestamps: duration = end - start + 1
  • Adjusting parent start time after child completes
  • Single-threaded CPU means no overlapping calls
  • Time and space complexity analysis
  • Handling multiple top-level function calls

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