Problem bank
Problem 248 of 333HardCodingP248
Currency arbitrage across many currencies
You are given an matrix
rateswhererates[i][j]is how many units of currency you get for one unit of currency . Write a function that returns whether some cycle of conversions turns 1 unit of a currency into more than 1 unit of the same currency. State the complexity.Test it on three currencies USD, EUR, JPY with USD→EUR 0.9, EUR→JPY 160 and JPY→USD 0.0070. Fill each reverse rate with the reciprocal (EUR→USD is , and so on) and put 1 on the diagonal.
See the hint and solution with a free account
Every problem on Quant Engine is free, with a hint and a full worked solution. Making an account takes 30 seconds and no card. Then you can see them and track what you have solved.