Reported September 2026
Mercorgraph

Currency Conversion Rate

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

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

The Mercor OA reported in September 2026 hands you a pile of currency rates and asks for one conversion. It's a graph problem wearing a finance costume. The mistake that sinks a first attempt is treating the rates as one-directional, so GBP to AUD never resolves. Every listed rate also works in reverse as a reciprocal, and the answer has to print with exactly two decimals. If you've seen a path-multiplication problem before, this is the same shape. If you blank when the clock starts, StealthCoder is the safety net running invisibly during the live OA.

The problem

You are given currency conversion rates. Each row contains a source currency, a target currency, and the value of one unit of the source currency in the target currency.
A conversion may use multiple rates. A listed rate may also be used in reverse by taking its reciprocal.
Given a query [from, to], return the conversion rate from from to to, rounded and formatted with exactly two digits after the decimal point. Every judged query is connected by the supplied rates.

Function
findConversionRate(rates: String[][], query: String[]) → String

Examples
Example 1
rates = [["USD","JPY","110"],["USD","AUD","1.45"],["JPY","GBP","0.0070"]]
query = ["GBP","AUD"]
return = "1.88"
Use the reverse of JPY -> GBP, then the reverse of USD -> JPY, then USD -> AUD: (1 / 0.0070) * (1 / 110) * 1.45 = 1.883116.... Rounded to two decimal places, the result is 1.88.
Example 2
rates = [["USD","CAD","1.30"],["CAD","EUR","0.70"]]
query = ["USD","EUR"]
return = "0.91"
One USD is 1.30 CAD, and one CAD is 0.70 EUR, so the rate is 1.30 * 0.70 = 0.91.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build an undirected-style graph. For each row [a, b, r], add edge a to b with weight r and edge b to a with weight 1/r. Then run BFS or DFS from the source, carrying the product of weights so far. When you reach the target, return that product. Every judged query is connected, so you don't need a no-path case, but guard the same-currency query by returning 1.00. The pitfall is forgetting the reverse edge, which breaks Example 1 where GBP to AUD needs two reciprocals before the forward USD to AUD hop. Second pitfall: formatting. Use fixed two-decimal formatting, not manual rounding and string trimming. Mark visited nodes so cycles don't loop forever. Union-find with weights works too, but BFS is faster to write under pressure. If the graph logic slips mid-assessment, StealthCoder can supply the working traversal.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Currency Conversion Rate 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as evaluate division. If you have time before the OA, drill that.

⏵ The honest play

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

Mercor reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Currency Conversion Rate FAQ

What's the trick in the Mercor currency conversion question?+

Model currencies as nodes and rates as weighted edges. Add each rate in both directions, the original and its reciprocal. Then search from the source to the target, multiplying weights along the path. Any path works because the rates are consistent, so the first one found gives the answer.

Should I use BFS or DFS?+

Either works. Both find a path in linear time over the edges. BFS with a queue of (currency, product) pairs is easy to write and avoids recursion depth worries. Keep a visited set so cycles in the rate graph don't cause infinite loops.

How do I format the output to two decimals?+

Use your language's fixed-point formatting, like a format string with two digits after the decimal point. Return a string, not a number. Example 1 gives 1.883116 internally and must come back as "1.88". Don't truncate, let the formatter round.

What edge cases should I check?+

Query where from equals to should return "1.00". Check a path needing only reverse edges, like Example 1's start. Check currencies appearing in several rows, which creates cycles. Every judged query is connected, so you don't need to handle missing paths.

How do I prepare for this in 48 hours?+

Write a weighted graph BFS once from scratch, including the reciprocal edge. Then run both examples by hand and confirm 1.88 and 0.91. That covers the whole question. Similar problems on division equations use the identical structure, so one clean implementation transfers.

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

OA at Mercor?
Invisible during screen share
Get it