← Meta Interview Insights

Meta·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Two coding problems at Meta for an MLE role. Nothing ML-specific, just straight algorithms. The second problem was nastier than it looked.

Questions Asked (2)

Q1

Given an array of package weights and a number of days D, find the minimum ship capacity needed to deliver all packages in order within D days.

Algorithms & Data Structures
Author's notes

Binary search on the answer.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the minimum capacity lies between the maximum package weight and the sum of all weights. Use binary search on the capacity and for each candidate, simulate the shipping process greedily to check if all packages can be delivered within D days. Return the smallest feasible capacity.

Pro tip: Clarify that packages must be shipped in the given order, so a greedy simulation is valid. Mention that binary search reduces the time complexity to O(n log(sum(weights))), which is efficient for large inputs.

1. Define search bounds

Set the lower bound to the maximum package weight (since capacity cannot be less than the heaviest package) and the upper bound to the sum of all weights (a single day shipment).

2. Binary search for capacity

While lower bound < upper bound, compute mid capacity and check if it's feasible to ship within D days using a greedy simulation.

3. Feasibility check

Simulate shipping: iterate through packages, accumulate weights until adding the next would exceed capacity, then increment day count and start a new day. If days exceed D, capacity is too small.

4. Adjust bounds

If feasible, set upper bound to mid; otherwise set lower bound to mid+1. Continue until bounds converge.

5. Return result

The converged lower bound is the minimum ship capacity needed.

Key Points to Mention

  • Binary search on the answer space
  • Greedy simulation for feasibility check
  • Time complexity: O(n log(sum(weights)))
  • Space complexity: O(1)
  • Handling edge cases: D >= number of packages, D = 1
  • Order preservation constraint

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

Q2

Given a digit string and a target integer, return all expressions formed by inserting '+', '-', or nothing between digits that evaluate to the target.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Backtracking, but the leading zeros edge case and the concatenation tracking both bit me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use backtracking to explore all possible ways to split the digit string into numbers and insert operators, maintaining the current expression and its evaluated value. Handle multiplication by tracking the last operand to correctly adjust the value when a '*' is inserted, since multiplication has higher precedence than addition and subtraction.

Pro tip: Clarify with the interviewer whether the expression should be built left-to-right with standard operator precedence (which requires the last-operand trick) or if they expect a simpler approach without precedence. Also, discuss how to handle leading zeros in multi-digit numbers, as this is a common edge case.

1. Clarify requirements and edge cases

Ask about operator precedence, handling of leading zeros, and whether the output should include duplicate expressions. Confirm that the digit string can be split into multi-digit numbers.

2. Design recursive backtracking

Define a recursive function that processes the digit string from left to right, building the current expression and tracking the current evaluated value and the last operand (for multiplication).

3. Handle operator insertion and evaluation

At each step, try inserting '+', '-', or nothing (concatenation) between the current number and the next digit(s). For multiplication, adjust the value by subtracting the last operand and adding the product.

4. Prune and optimize

Discuss potential pruning: if the remaining digits cannot possibly reach the target due to magnitude, or if using memoization to avoid recomputing subproblems (though state includes expression, so memoization is tricky).

5. Analyze complexity and trade-offs

Explain that the time complexity is exponential (O(4^n) in the worst case) due to branching, and space complexity is O(n) for recursion depth. Mention iterative approaches or dynamic programming as alternatives but note backtracking is standard.

Key Points to Mention

  • Backtracking with recursion to explore all possibilities
  • Handling operator precedence, especially multiplication, by tracking the last operand
  • Edge cases: leading zeros, empty string, target not reachable
  • Time and space complexity analysis
  • Potential optimizations like pruning or memoization
  • Clear communication of thought process and trade-offs

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