Best Time to Buy and Sell Stock II
Find the maximum profit from buying and selling stock with unlimited transactions. You may hold at most one share at a time.

30:00

Best Time to Buy and Sell Stock II
medium
Topics
Companies

Find the maximum profit from buying and selling stock with unlimited transactions. You may hold at most one share at a time.

Example 1:
Input: [7,1,5,3,6,4]
Output: 7
Constraints:
  • 1prices.length3×1041 \leq \text{prices.length} \leq 3 \times 10^4

  • 0prices[i]1040 \leq \text{prices}[i] \leq 10^4

Input
arr =[7,1,5,3,6,4]
7
i
Day 0
1
Day 1
5
Day 2
3
Day 3
6
Day 4
4
Day 5
Current Index
0
Current Gain
-
Total Profit
0
Transactions
0
Variables
No variables to display
DepthFunction Call
Stack empty
0/13