FastPrepCurrency Conversion Through Exchange Paths
Problems/Currency Conversion Through Exchange Paths

Currency Conversion Through Exchange Paths

Stripe logoStripe● MediumFULLTIMENEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe phone screen. The source gives the rate strings, a direct conversion that can be turned around, a worked example with one stop in between, and the follow-up for paths of any length. It does not say what to return when a currency can't be reached, the rounding rule, or the function signature. We limit queries to currencies that connect, and we use double precision. Our version is about 94% the same as the reported question.

You are given directed currency rates as from,to,rate. A rate of USD,CAD,1.26 means one USD converts to 1.26 CAD. Every supplied rate may also be used in reverse with reciprocal value.

For each source,target query, return the conversion rate from source to target. The currencies may be directly related, connected through one intermediate currency, or connected through an arbitrary number of intermediate currencies.

All queries are connected, rates are positive, and every cycle is consistent, so every valid path between the same two currencies gives the same result.

Function

convertCurrencies(rates: String[], queries: String[]) → double[]

Examples

Example 1

rates = ["USD,CAD,1.26","USD,AUD,0.75","USD,JPY,109.23"]queries = ["CAD,USD","CAD,AUD"]return = [0.7936507937,0.5952380952]

CAD to USD uses the reciprocal of 1.26. CAD to AUD follows CAD → USD → AUD.

Example 2

rates = ["EUR,GBP,0.86","GBP,JPY,190","JPY,KRW,9.1"]queries = ["EUR,KRW","KRW,GBP"]return = [1486.94,0.0005786008]

The first query multiplies three forward edges. The second uses the reciprocals of KRW → JPY and JPY → GBP.

Constraints

  • 1 <= rates.length, queries.length <= 10000.
  • Currency codes are non-empty and contain no commas.
  • Every rate is finite and strictly positive.
  • Every query's currencies exist in the same connected component.
  • All supplied rates are mutually consistent.
  • Answers are accepted within 1e-6 absolute or relative error.

More Stripe Phone Screen questions

  • Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Payout Reserve CalculatorPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
  • Validate and Resolve Evaluation ChainsPlaid · PHONE SCREEN · ONSITE INTERVIEWPlaid interview questions
  • Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
  • Root of the Largest TreeGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Find the Unique User with Access to Every CameraVerkada · PHONE SCREENVerkada interview questions
  • Unique Transitive Dependent CountsRobinhood · PHONE SCREENRobinhood interview questions
  • Maximum Programmer-Problem MatchingGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Best Currency Round Trip Over Two DaysRippling · PHONE SCREENRippling interview questions

Interview reports that mention this question

  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe OA: What It Tests (2026)
  • Stripe SWE Onsite over Two Days: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public double[] convertCurrencies(String[] rates, String[] queries) {
      // write your code here
    }
}
Checking account…