FastPrepBest Currency Round Trip Over Two Days
Problems/Best Currency Round Trip Over Two Days

Best Currency Round Trip Over Two Days

Rippling logoRippling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Rippling software engineer review from March 2026 lists this task among the coding questions: turn your money into other currencies with one day's rates, then trade again with a second day's rates, and end with as much of the starting currency as possible. The review gives only the task's name, with no rules, limits or examples.

Here, you start with 1 unit. Every pair also trades backward at one over its rate. Each day may use any number of trades or none. Each day's pairs form no loop, so rates never disagree. Currencies are 3-letter codes. Answers within 10^-5 (relative for large values) are accepted. The limits and examples are our own.

Our version is about 70% the same as the reported question.

You hold 1 unit of the currency startCurrency. You may trade currencies on two days, first on day 1 and then on day 2.

On day 1, dayOnePairs[i] = [from, to] with rate dayOneRates[i] means one unit of from buys dayOneRates[i] units of to. The trade also works backward: one unit of to buys 1 / dayOneRates[i] units of from. Day 2 works the same way with dayTwoPairs and dayTwoRates.

Each day you may make any number of trades (including none) using only that day's pairs. You always hold your whole amount in one currency. Return the largest amount of startCurrency you can hold at the end of day 2.

Your answer is accepted if it differs from the exact value v by at most 10^-5 * max(1, |v|).

Function

bestTwoDayAmount(startCurrency: String, dayOnePairs: String[][], dayOneRates: double[], dayTwoPairs: String[][], dayTwoRates: double[]) → double

Examples

Example 1

startCurrency = "USD"dayOnePairs = [["USD","CAD"],["CAD","MXN"]]dayOneRates = [1.5,9.6]dayTwoPairs = [["MXN","USD"],["USD","CAD"]]dayTwoRates = [0.1,1.2]return = 1.44

On day 1: 1 USD becomes 1.5 CAD, then 1.5 × 9.6 = 14.4 MXN. On day 2: 14.4 MXN becomes 14.4 × 0.1 = 1.44 USD. Going through CAD instead gives only 1.5 / 1.2 = 1.25 USD on day 2. The best final amount is 1.44.

Example 2

startCurrency = "EUR"dayOnePairs = [["GBP","EUR"]]dayOneRates = [1.25]dayTwoPairs = [["EUR","GBP"]]dayTwoRates = [0.8]return = 1.0

On day 1 the pair says 1 GBP buys 1.25 EUR, so 1 EUR buys 1 / 1.25 = 0.8 GBP. On day 2, 0.8 GBP buys back 0.8 / 0.8 = 1 EUR. No trade gains anything, so the answer is 1.0 (you may also make no conversions at all).

Example 3

startCurrency = "JPY"dayOnePairs = [["JPY","KRW"]]dayOneRates = [9.0]dayTwoPairs = [["CHF","SEK"]]dayTwoRates = [6.5]return = 1.0

On day 1 you can turn JPY into KRW, but day 2 has no pair that leads back to JPY from KRW. Keep the 1 JPY: the answer is 1.0.

Constraints

  • 1 <= dayOnePairs.length, dayTwoPairs.length <= 10
  • dayOneRates.length == dayOnePairs.length and dayTwoRates.length == dayTwoPairs.length
  • startCurrency and every currency in a pair is exactly 3 uppercase English letters, and the two currencies in a pair are different.
  • 0.1 <= rate <= 10, with at most 2 digits after the decimal point
  • Within one day, the pairs never form a loop of currencies, so no two pairs join the same two currencies and the rates never disagree.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
  • Page Referrer ReachabilityAmazon · ONSITE INTERVIEW
  • Reachable Nodes in a Directed GraphSoFi · ONSITE INTERVIEWSoFi interview questions
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Evaluate DivisionApple · PHONE SCREENApple interview questions
  • Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
  • Validate and Resolve Evaluation ChainsPlaid · PHONE SCREEN · ONSITE INTERVIEWPlaid interview questions

Interview reports that mention this question

  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public double bestTwoDayAmount(String startCurrency, String[][] dayOnePairs, double[] dayOneRates, String[][] dayTwoPairs, double[] dayTwoRates) {
        // Write your code here.
    }
}
Checking account…