Solved LeetCode program · 875 of 1,000
#1191 · K-Concatenation Maximum Sum
Original English source
The numbers is a list of 1 and 2. The rounds is 3. The total is 0.
For each value in numbers.
Add value to total.
The current is 0. The best is 0.
For each value in numbers.
Set current to the larger of current plus value and value. Set best to the larger of best and current.
The answer is best. If rounds is more than 1 and total is more than 0, set answer to best plus (total times (rounds minus 1)).
Show answer.
Expected stdout
9