FastPrepProfitable Currency Exchange Cycle
Problems/Profitable Currency Exchange Cycle

Profitable Currency Exchange Cycle

Optiver logoOptiver● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optiver online assessment. The report gives the goal of finding an exchange cycle and the single fee on the starting amount. It does not give the matrix format, how long a cycle can be, the input limits, or the precision rule. We added those. Our version is about 92% the same as the reported question.

The square matrix rates describes currency conversions. Exchanging one unit of currency i into currency j yields rates[i][j] units.

An exchange cycle begins and ends at the same currency and uses between 1 and rates.length exchanges, inclusive. Intermediate currencies may repeat. The exchange-rate product is applied to the starting amount, then one fee equal to 0.01% of the starting amount is charged.

Return true when some allowed cycle is strictly profitable after that one fee; otherwise return false.

Function

hasProfitableExchangeCycle(rates: double[][]) → boolean

Examples

Example 1

rates = [[1.0,1.1,0.9],[0.9,1.0,1.1],[1.0,0.9,1.0]]return = true

The cycle 0 -> 1 -> 2 -> 0 multiplies your money by 1.21. After the fee, you still have more than 1 unit for each unit you started with, so the answer is true.

Example 2

rates = [[1.0,0.9],[1.1,1.0]]return = false

Going to the other currency and back multiplies your money by 0.99. Exchanging a currency into itself multiplies it by 1. None of these cycles makes a profit after the fee, so the answer is false.

Constraints

  • 1 <= rates.length <= 40
  • rates[i].length = rates.length
  • 10^-4 <= rates[i][j] <= 10^4
  • rates[i][i] = 1
  • For every allowed cycle, the sum of the logarithms of its rates is at least 10^-10 away from the break-even value. At that value, the cycle's gain exactly pays the fee.

More Optiver Online Assessment questions

  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026
  • Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026
  • Fastest Average Speed over a Rolling KilometerOA · Seen Sep 2026
  • Multi-Level Inventory Storage SystemOA · PHONE SCREEN · Seen Aug 2026
  • Proportional Momentum Investment StatisticsOA · Seen Aug 2026
  • Count Bounded Share TransactionsOA · Seen Aug 2026
  • Count Ordered Size SequencesOA · Seen Aug 2026
  • Construct Binary Tree S-ExpressionOA · Seen Jul 2026
  • Days BetweenOA · Seen Jul 2026

Similar questions at other companies

  • Count Routes in a Divisor GraphExpedia · OAExpedia interview questions
  • At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Maximum Signal Walk in a Server TreeTower Research Capital · OA
  • Count Nondecreasing Digit-Sum ArraysMicrosoft · OAMicrosoft interview questions
  • Jump Game with Prime-3 StepsUber · OAUber interview questions
  • Minimum Numeric Code TransformationAdobe · OAAdobe interview questions
  • Drone Delivery with Battery Swap StationsCisco · OACisco interview questions
  • Match an XOR-Adjusted SumSquarepoint Capital · OASquarepoint Capital interview questions
  • Count Numbers with a Prime Digit SumRippling · OARippling interview questions

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public boolean hasProfitableExchangeCycle(double[][] rates) {
        // write your code here
    }
}
Checking account…