← Snapchat Interview Insights

Snapchat·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Snapchat ML Engineer interview with a coding round that was more of a math-precision trap than a pure DP problem. The question looked like standard coin change until you realized floating-point was the whole point.

Questions Asked (1)

Q1

Given a list of coin denominations as decimal values and a decimal target amount, find the minimum number of coins that sum exactly to the target. Each denomination can be used any number of times. Return -1 if no exact combination exists. You must avoid running DP directly on floats.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was to just throw DP at it with floats and call it a day.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Convert all decimal denominations and the target amount to integer cents by multiplying by 100 and rounding to avoid floating-point errors. Then apply a standard dynamic programming approach for the unbounded coin change problem on the integer values, returning the minimum number of coins or -1 if impossible.

Pro tip: Mention that using integers (cents) is crucial for exactness and performance, and that you can optimize space by using a 1D DP array. Also, note that if the target is large, a BFS approach might be more efficient for finding the minimum coins.

1. Clarify and Convert

Confirm that denominations and target are decimal values, then convert them to integer cents by multiplying by 100 and rounding to the nearest integer to avoid floating-point precision issues.

2. Handle Edge Cases

Check for invalid inputs: if target is 0, return 0; if any denomination is 0 or negative, or if target is negative, return -1. Also, if the target is not reachable, return -1.

3. Choose DP Approach

Use dynamic programming with a 1D array of size target+1, initialized to infinity (or a large number), with dp[0] = 0. For each coin, iterate through the array and update dp[i] = min(dp[i], dp[i - coin] + 1).

4. Optimize and Analyze

Discuss time and space complexity: O(target * number of denominations) time and O(target) space. Mention potential optimizations like using BFS for sparse targets or pruning denominations larger than target.

5. Return Result

After filling the DP array, if dp[target] is still infinity, return -1; otherwise, return dp[target] as the minimum number of coins.

Key Points to Mention

  • Floating-point precision issues and why converting to integer cents is necessary.
  • Dynamic programming recurrence: dp[i] = min(dp[i], dp[i - coin] + 1).
  • Time and space complexity: O(target * number of denominations) time, O(target) space.
  • Handling of edge cases: target = 0, unreachable target, invalid denominations.
  • Alternative approaches: BFS for minimum coins, greedy algorithm limitations (only works for canonical coin systems).
  • Potential optimizations: sorting denominations, using a queue for BFS, or pruning coins larger than target.

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