Detect a Currency Arbitrage Cycle From Exchange Rates

Last updated: November 29, 2026

Quick Overview

Given a set of currencies and directed exchange rates between them, determine whether some cycle of conversions multiplies to more than 1, and if so return one such cycle.

Akuna Capital
Coding & Algorithms
Quantitative Researcher
Akuna Capital
November 29, 2026
Quantitative Researcher
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a set of currencies and directed exchange rates between them, determine whether some cycle of conversions multiplies to more than 1, and if so return one such cycle.

Akuna Capital's interviews blend algorithms with trading intuition, and arbitrage detection maps directly to how a market maker thinks about inconsistent prices. The interviewer checks that you convert products to sums with logarithms, know Bellman-Ford's negative-cycle property, and can actually recover the cycle.

What the Interviewer Expects
  • Transform rate products into sums with weight -log(rate)
  • Explain why a profitable cycle is a negative cycle
  • Use Bellman-Ford from a virtual source so every component is covered
  • Recover the cycle by walking parent pointers n steps first
  • Mention floating-point tolerance and transaction costs
Key Topics to Cover
Bellman-Ford
negative cycles
logarithms
weighted graphs
arbitrage
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 incorporate bid/ask spreads and fees?
  • How would you find the most profitable cycle rather than any cycle?
  • Rates update continuously: how would you avoid rerunning from scratch?
  • 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: currencies and a dict (a, b) -> rate meaning 1 unit of a buys rate units of b. Output: a list like [USD, JPY, USD] whose product of rates exceeds 1, or None....

High-Level Design

A cycle is profitable when the product of its rates is above 1, which is the same as the sum of log rates being positive, or the sum of -log rates being negative. So set each edge weight to -log(rate)...


Submit Your Answer
Markdown supported

Related Questions