<p>You are given two integer arrays <code>energyDrinkA</code> and <code>energyDrinkB</code> of the same length <code>n</code> by a futuristic sports scientist. These arrays represent the energy boosts per hour provided by two different energy drinks, A and B, respectively.</p>

<p>You want to <em>maximize</em> your total energy boost by drinking one energy drink <em>per hour</em>. However, if you want to switch from consuming one energy drink to the other, you need to wait for <em>one hour</em> to cleanse your system (meaning you won&#39;t get any energy boost in that hour).</p>

<p>Return the <strong>maximum</strong> total energy boost you can gain in the next <code>n</code> hours.</p>

<p><strong>Note</strong> that you can start consuming <em>either</em> of the two energy drinks.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> energyDrinkA<span class="example-io"> = [1,3,1], </span>energyDrinkB<span class="example-io"> = [3,1,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">5</span></p>

<p><strong>Explanation:</strong></p>

<p>To gain an energy boost of 5, drink only the energy drink A (or only B).</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> energyDrinkA<span class="example-io"> = [4,1,1], </span>energyDrinkB<span class="example-io"> = [1,1,3]</span></p>

<p><strong>Output:</strong> <span class="example-io">7</span></p>

<p><strong>Explanation:</strong></p>

<p>To gain an energy boost of 7:</p>

<ul>
	<li>Drink the energy drink A for the first hour.</li>
	<li>Switch to the energy drink B and we lose the energy boost of the second hour.</li>
	<li>Gain the energy boost of the drink B in the third hour.</li>
</ul>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == energyDrinkA.length == energyDrinkB.length</code></li>
	<li><code>3 &lt;= n &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= energyDrinkA[i], energyDrinkB[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def maxEnergyBoost(self, energyDrinkA: List[int], energyDrinkB: List[int]) -> int:
        # 1. Input Output Non Trivial Example
        # 2. Intuition - data structure or algorithm. (Based on experience and skill).
        # 3. Execution intuition on example.
        # 4. Invariant - Some truth, heart of our algorithm, that proves algorithm's correctness.
        # 5. Writing in english the explanation of the algorithm step by step
        # 6. I execute/debug the english algo on example.
        # 7. Writing down the code - clean code (a little skill)
        # 8. I execute/debug the code on example.

        # non trivial example: [100, 100, 1, 300], [4, 204, 200, 99]
        # intuition - some kind of dp
        # [100, 100, 1, 300], [4, 204, 200, 99]
        # if i choose to switch and come back
        # i loose one, consume, loose one
        # dp[i][j] = max(dp[(i+1)%2][j-2], dp[i][j-1]) + input[i][j]
        # dp[0][0] = 100, dp[0][1] = 200, dp[1][0] = 4, dp[1][1] = 208
        # we first fill the basis of dp
        # then we iterate over j!! and within j iterate over i
        # in each iteration we apply the formula
        # return the max val
        # dp[0][2] = max(4, 200) + 1 = 201
        # dp[1][2] = max(100, 208) + 200 = 408
        # dp[0][3] = max(dp[1,1]=208, dp[0,2]=201) + 300 = 508
        # dp[1][3] = max(dp[0,1]=200, dp[1,2]=408) + 99 = 507
        # result is => input[1][0] input[1][1] + input[0][3]  
        energies = [energyDrinkA, energyDrinkB]     
        dp = [[0] * len(energyDrinkA),[0] * len(energyDrinkA)]
        dp[0][0] = energies[0][0]
        dp[0][1] = energies[0][0] + energies[0][1]
        dp[1][0] = energies[1][0]
        dp[1][1] = energies[1][0] + energies[1][1]
        for j in range(2, len(dp[0])):
            for i in range(len(dp)):
                dp[i][j] = max(dp[(i+1)%2][j-2], dp[i][j-1]) + energies[i][j]
        print(dp)
        return max(dp[0][len(dp[0]) - 1], dp[1][len(dp[0]) - 1])

        





45615