Implement a currency exchange calculator for conversion queries.
Unlock detailed company stats for this questionUpgrade
Input is a list of exchange rates in the form [currency1, currency2, exchangeRate]. Queries have the form [currency1, currency2, amountInCurrency1]; return the converted amount. Model as a graph with currencies as nodes and rates as weighted edges; add reverse edges with inverse rates; handle cycles with a visited state. Follow-up: how to handle cycles in the graph.
Expect follow-ups like
- How would you handle cycles in the graph?
Format · Live implementation with dry runs.
Community answers
No answers contributed by the community yet.
Related questions
Implement a currency exchange that converts between currencies given rates.Given currency exchange rates, compute the conversion rate between two currencies.Related courses

Course

Course
Course
