Reported November 2025
Bloombergbreadth first search

Shortest Currency Conversion Chain

Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Bloomberg OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Bloomberg question is treating it as plain shortest path and ignoring the tie-break. It was reported in November 2025, and it's a graph problem in disguise. You get currency pairs, undirected edges, a source and a target. Return the fewest-hop chain, and when two chains tie, return the lexicographically smaller full sequence. Disconnected means an empty array. It looks easy until your output flips on one test. If you blank on the tie-break during the live OA, StealthCoder runs invisibly as a safety net and shows you the approach.

The problem

Each row in pairs lists two currencies with a direct conversion and may be traversed in either direction. Return a chain from source to target using the fewest edges.
Break equal-hop ties by lexicographically comparing the complete currency sequences. Return an empty array when disconnected.

Function
shortestConversionChain(pairs: String[][], source: String, target: String) → String[]

Examples
Example 1
pairs = [["USD","CAD"],["CAD","MEX"],["USD","EUR"],["EUR","MEX"]]
source = "USD"
target = "MEX"
return = ["USD","CAD","MEX"]
Both routes use two edges; the CAD route is lexicographically smaller.

Constraints
Currency names are nonempty strings.
Pairs contain no self edges.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build an adjacency map from the pairs, adding both directions. Then run BFS from the source. The trick is the tie-break. Sort each node's neighbors alphabetically before exploring, and record the parent only the first time a node is discovered. Because BFS processes level by level in sorted order, the first discovery of each node comes via the lexicographically smallest path at that depth. Rebuild the chain by walking parents back from the target, then reverse it. The common pitfall is running a plain BFS with unsorted neighbors, or comparing only the last node instead of the whole sequence. Also handle the case where the source or target isn't in the graph, and return an empty array. If the live OA has you stuck on why the sorted order guarantees the smallest path, StealthCoder is your hedge. It reads the problem and hands you working code.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Shortest Currency Conversion Chain cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Bloomberg's OA.

Bloomberg reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Shortest Currency Conversion Chain FAQ

What's the trick in the Bloomberg shortest currency conversion chain problem?+

It's BFS with a deterministic tie-break. Sort neighbors alphabetically, set each node's parent on first discovery only, and rebuild the path from the target. BFS gives the fewest edges, and the sorted order makes the first path found at each depth the lexicographically smallest.

Why can't I just use Dijkstra?+

You can, but it's overkill. Every edge costs one hop, so BFS finds the minimum edge count in linear time. Dijkstra would also need extra logic to compare whole sequences on ties, which makes the code messier and easier to get wrong.

How does the lexicographic tie-break actually work?+

Compare the complete sequences, not just the final node. With sorted neighbor expansion in BFS, the earliest parent assignment corresponds to the smallest prefix at every level. So the reconstructed path is the smallest among all shortest paths. In Example 1, CAD beats EUR.

What edge cases should I test?+

Disconnected source and target should return an empty array. Also test a source or target missing from the pairs, duplicate pairs, and several equal-length routes. Pairs have no self edges, so you don't need to handle loops, but a visited set still protects against cycles.

How do I prepare for this in 48 hours?+

Write BFS shortest path with parent tracking from scratch twice, once on an adjacency list built from edge pairs. Then add sorted neighbors for the tie-break. Practice rebuilding and reversing the path. That covers this question and most of its variants.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Bloomberg.

OA at Bloomberg?
Invisible during screen share
Get it