← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a list of currency exchange rates represented as triplets [from_currency, to_currency, rate], meaning 1 unit of from_currency can be exchanged for rate units of to_currency. Exchange rates are bidirectional: if the rate from A to B is r, then the rate from B to A is 1/r. You are also given a list of queries, each query is a pair [from_currency, to_currency]. For every query you must compute the best (i.e. maximum-product) exchange rate achievable by any sequence of zero or more intermediate exchanges. If no conversion path exists, return -1.0 for that query. Implement the function that returns a list of answers in the same order as the queries.