← Snap Interview Insights

Snap·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Snap SWE interview with a graph/ratio problem that sounds deceptively straightforward until you actually try to implement it cleanly.

Questions Asked (1)

Q1

Given a list of conversion relationships between symbols (e.g. currency or unit pairs), write an algorithm that returns the conversion ratio for any given pair of symbols.

Algorithms & Data Structures
Author's notes

This is basically a graph traversal problem in disguise.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the conversion relationships as a directed graph where symbols are nodes and conversion rates are weighted edges. Then, for any query pair, perform a graph traversal (e.g., BFS/DFS) to find a path and compute the cumulative conversion ratio by multiplying edge weights. Handle edge cases like unknown symbols or no path by returning an error or sentinel value.

Pro tip: Clarify upfront whether the graph is guaranteed to be connected and whether rates are consistent (e.g., no arbitrage). This shows you think about real-world constraints and can discuss trade-offs between precomputing all pairs (Floyd-Warshall) vs. on-demand traversal.

1. Clarify requirements and assumptions

Ask about input format, whether the graph is directed, if rates are consistent, and if queries are frequent. This ensures you design the right solution.

2. Model as a graph

Represent symbols as nodes and conversion rates as directed edges with weights. For bidirectional conversions, add reverse edges with reciprocal weights.

3. Choose traversal algorithm

Use BFS or DFS to find a path from source to target. BFS finds the shortest path in terms of edges, which is often preferred for simplicity.

4. Compute conversion ratio

During traversal, maintain the cumulative product of edge weights. Once the target is reached, return the product as the conversion ratio.

5. Handle edge cases and optimize

Return an error if no path exists or symbols are invalid. Discuss optimizations like caching results or precomputing all pairs if queries are frequent.

Key Points to Mention

  • Graph representation: adjacency list with weighted edges
  • Traversal algorithm: BFS/DFS with cumulative product
  • Handling bidirectional conversions by adding reciprocal edges
  • Edge cases: unknown symbols, no path, zero or negative rates
  • Time and space complexity: O(V+E) per query, O(V+E) space
  • Optimization: precompute all pairs with Floyd-Warshall for frequent queries

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