Detect a Currency Arbitrage Loop From Quoted Rates

Last updated: November 29, 2026

Quick Overview

Given currencies and directed conversion rates (one unit of A buys r units of B), determine whether some cycle of conversions turns one unit into more than one unit, and return one such cycle.

SIG
Coding & Algorithms
Software Engineer
SIG
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given currencies and directed conversion rates (one unit of A buys r units of B), determine whether some cycle of conversions turns one unit into more than one unit, and return one such cycle.

SIG trades across many venues and products where implied prices form loops, so a question about finding a profitable cycle in a rate graph fits its onsite well. The interviewer looks for the log transform to a negative-cycle problem, a correct Bellman-Ford, and careful cycle reconstruction.

What the Interviewer Expects
  • Transform products of rates into sums with weight -log(rate)
  • Recognize a profitable loop as a negative cycle
  • Run Bellman-Ford from a virtual source so every component is covered
  • Reconstruct a cycle by walking parents n times first
  • Discuss floating-point tolerance and transaction costs
Key Topics to Cover
Bellman-Ford
negative cycle
log transform
graph algorithms
floating point
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you include bid-ask spreads and per-trade fees?
  • Which cycle would you report if you want the most profitable, and why is that hard?
  • How would you keep this up to date as rates tick thousands of times per second?
  • Why does Dijkstra not work here?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of currency names and edges (src, dst, rate). A loop is profitable if the product of rates around it exceeds 1. Return the loop as a list starting and ending at the same currency, or `No...

High-Level Design

Product greater than 1 means sum of log(rate) greater than 0, which means sum of -log(rate) less than 0. So set edge weight w = -log(rate) and look for a negative cycle. Bellman-Ford relaxes all...


Submit Your Answer
Markdown supported

Related Questions