Currency arbitrage detection

Write codeHard35 minCitadel and Bloomberg style

Your task

A trading desk has a matrix rates where rates[i][j] is how many units of currency j you get for one unit of currency i (rates[i][i] = 1, and rates[i][j] <= 0 means no direct conversion). An arbitrage opportunity exists if you can start with one unit of some currency, convert through a sequence of currencies, and return to the start with strictly more than one unit. Return True if any such opportunity exists, otherwise False. There are at most 50 currencies.

Examples

has_arbitrage(rates: list[list[float]]) -> bool
Example 1
Inputhas_arbitrage([[1, 2], [0.6, 1]])
OutputTrue