Tap here to switch tabs
Problem
Submissions

Problem: Maximize Amount After Two Days of Conversions

Maximize Amount After Two Days of Conversions starts with one unit of a currency and two days of exchange rates. Return the maximum starting currency amount after both days.

Statement

You are given a string initialCurrency and conversion rates for two consecutive days.

You start on Day 11 with 1.01.0 unit of initialCurrency.

For Day 11, you are given a 2D2 {D} string array pairs1 and a floating point array rates1, where pairs1[i] = [startCurrency_i, targetCurrency_i] indicates that 1.01.0 unit of startCurrency_i converts to rates1[i] units of targetCurrency_i, and 1.01.0 unit of targetCurrency_i converts to 1.0/rates1[i]1.0 / {rates1[i]} units of startCurrency_i.

For Day 22, you are given a 2D2 {D} string array pairs2 and a floating point array rates2, which define currency conversions for Day 22 in the same manner.

On each day, you may perform any number of currency conversions using the rates available for that day. Conversions can only be made using the rates of the respective day.

Return the maximum amount of initialCurrency you can obtain by the end of Day 22.

Constraints:

  • 1≤1 \leq initialCurrency.length ≤3\leq 3

  • initialCurrency consists only of uppercase English letters.

  • 1≤n==1 \leq n == pairs1.length ≤10\leq 10

  • 1≤m==1 \leq m == pairs2.length ≤10\leq 10

  • pairs1[i] == [startCurrency_i, targetCurrency_i]

  • pairs2[i] == [startCurrency_i, targetCurrency_i]

  • 1≤1 \leq startCurrency_i.length, targetCurrency_i.length ≤3\leq 3

  • startCurrency_i and targetCurrency_i consist only of uppercase English letters.

  • rates1.length ==n== n

  • rates2.length ==m== m

  • 1.0≤1.0 \leq rates1[i], rates2[i] ≤10.0\leq 10.0

  • The input is generated such that there are no contradictions or cycles in the conversion graphs for either day.

  • The input is generated such that the output is at most 5×10105 \times 10^{10}.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Amount After Two Days of Conversions

Maximize Amount After Two Days of Conversions starts with one unit of a currency and two days of exchange rates. Return the maximum starting currency amount after both days.

Statement

You are given a string initialCurrency and conversion rates for two consecutive days.

You start on Day 11 with 1.01.0 unit of initialCurrency.

For Day 11, you are given a 2D2 {D} string array pairs1 and a floating point array rates1, where pairs1[i] = [startCurrency_i, targetCurrency_i] indicates that 1.01.0 unit of startCurrency_i converts to rates1[i] units of targetCurrency_i, and 1.01.0 unit of targetCurrency_i converts to 1.0/rates1[i]1.0 / {rates1[i]} units of startCurrency_i.

For Day 22, you are given a 2D2 {D} string array pairs2 and a floating point array rates2, which define currency conversions for Day 22 in the same manner.

On each day, you may perform any number of currency conversions using the rates available for that day. Conversions can only be made using the rates of the respective day.

Return the maximum amount of initialCurrency you can obtain by the end of Day 22.

Constraints:

  • 1≤1 \leq initialCurrency.length ≤3\leq 3

  • initialCurrency consists only of uppercase English letters.

  • 1≤n==1 \leq n == pairs1.length ≤10\leq 10

  • 1≤m==1 \leq m == pairs2.length ≤10\leq 10

  • pairs1[i] == [startCurrency_i, targetCurrency_i]

  • pairs2[i] == [startCurrency_i, targetCurrency_i]

  • 1≤1 \leq startCurrency_i.length, targetCurrency_i.length ≤3\leq 3

  • startCurrency_i and targetCurrency_i consist only of uppercase English letters.

  • rates1.length ==n== n

  • rates2.length ==m== m

  • 1.0≤1.0 \leq rates1[i], rates2[i] ≤10.0\leq 10.0

  • The input is generated such that there are no contradictions or cycles in the conversion graphs for either day.

  • The input is generated such that the output is at most 5×10105 \times 10^{10}.