FastPrepCurrency Conversion Rate
Problems/Currency Conversion Rate

Currency Conversion Rate

Mercor logoMercor● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamples

Problem statement

Source note: The interview report identifies this task and its central operation. This practice version states the deterministic interface, boundary behavior, and ordering rules needed for consistent execution while preserving the reported capability.

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.

More Mercor problems

  • Expected Fake-Name CollisionsPHONE SCREEN · Seen Oct 2026
  • Length of a Document Reached Through a Random TokenPHONE SCREEN · Seen Oct 2026
  • Precision of Stacked PII Detector FlagsPHONE SCREEN · Seen Oct 2026
All Mercor interview questionsSee Mercor hiring insights
Saved
class Solution {
    public String findConversionRate(String[][] rates, String[] query) {
      // write your code here
    }
}
Checking account…