Practice Maximize Amount After Two Days of Conversions
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximize Amount After Two Days of Conversions
Problem Statement
Start with 1 unit of initialCurrency. On day 1, currencies may be converted using pairs1 and rates1; on day 2, use pairs2 and rates2. A listed pair converts in its given direction at its rate and in the reverse direction at the reciprocal rate. Perform any number of conversions on each day, completing day 1 before day 2. Each day’s rates are consistent. Return the maximum amount of initialCurrency obtainable after both days.
Source: Maximize Amount After Two Days of Conversions on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
initialCurrency = "EUR", pairs1 = [["EUR","USD"],["USD","JPY"]], rates1 = [2.0,3.0], pairs2 = [["JPY","USD"],["USD","CHF"],["CHF","EUR"]], rates2 = [4.0,5.0,6.0]
720.00000
# Example 2
initialCurrency = "NGN", pairs1 = [["NGN","EUR"]] , rates1 = [9.0] , pairs2 = [["NGN","EUR"]] , rates2 = [6.0]
1.50000
# Example 3
initialCurrency = "USD", pairs1 = [["USD","EUR"]], rates1 = [1.0], pairs2 = [["EUR","JPY"]], rates2 = [10.0]
1.00000
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize Amount After Two Days of Conversions.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.