Detect a Profitable Currency Loop in Cross-Border Payout Rates
Last updated: November 29, 2026
Quick Overview
Uber pays drivers in many currencies using a table of directed conversion rates. Detect whether some cycle of conversions multiplies money by more than 1 (an arbitrage loop that indicates a bad rate feed) and return one such cycle of currencies, or an empty list if none exists.
Uber
November 29, 20260
0
0 solved
Uber pays drivers in many currencies using a table of directed conversion rates. Detect whether some cycle of conversions multiplies money by more than 1 (an arbitrage loop that indicates a bad rate feed) and return one such cycle of currencies, or an empty list if none exists.
An onsite graph problem in the style of Uber's payments org, where a broken FX rate feed could leak money. The interviewer wants the log transform to turn products into sums, Bellman-Ford negative cycle detection, and correct cycle extraction from predecessor pointers.
What the Interviewer Expects
- Converts rates to weights with negative logarithms
- Uses Bellman-Ford with a virtual source to cover all components
- Detects a relaxation on the V-th pass
- Walks predecessors V times to land inside the cycle
- Discusses floating point tolerance
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you find the most profitable loop?
- How would you run this continuously as rates update every few seconds?
- What epsilon would you choose, and how do spreads and fees change the model?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of (src_ccy, dst_ccy, rate) with rate > 0. Output: a list of currencies forming a profitable cycle in order (first currency not repeated), or []. Use a small epsilon so rounding nois...
High-Level Design
A cycle is profitable when the product of rates exceeds 1, which is when the sum of is negative. Map currencies to ids, initialize every distance to 0 (equivalent to a virtual source with...