InterviewLegend

Currency Conversion: Weighted-Graph Path Product

Alex Chen16 min readUpdated 314 real interview reports

A Rippling interviewer hands you a handful of exchange rates and asks for conversions that are not on the list. You might be told what a dollar is worth in euros and what a euro is worth in yen. Then you get asked for dollars to yen, or yen back to dollars, or a pair with no connection at all. The rates you are given are single steps between neighbors, and each query wants the whole chain that links two currencies the list never connects directly.

Every rate is a directed edge in a small graph. A currency is a node, and a rate from one currency to another is an edge whose weight is the conversion factor. Give each edge a twin running the other way at the reciprocal weight, since a dollar worth two euros means a euro is worth half a dollar. A conversion is then a walk from the start node to the target, and the answer is the product of the weights along the way. If no walk exists, or either currency was never mentioned, the answer is -1.

What's inside
  • 1 problem, worked step by step
  • about 16 min

Premium lessonRippling interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Rippling interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Rippling interview guide

Know what Rippling asks before you walk in.

8 coding · 3 system design · 24 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.