Solved LeetCode program · 301 of 1,000
#0410 · Split Array Largest Sum
Original English source
Keep a shared nums holding 7, 2, 5, 10, and 8. Keep a shared limit of 0. Keep a shared need of 0. Keep a shared used of 0. Keep a shared parts of 0.
To weigh from spot (a whole number). If spot is more than 4, set need to parts, return. The value is item spot of nums. The filled is used plus value. If filled is at most limit, set used to filled. If filled is at most limit, weigh from spot plus 1, return. Add 1 to parts. Set used to value. Weigh from spot plus 1.
The last is the last position of nums. The allowed is 2. The low is 0. The total is 0.
For every spot from 0 to last.
The value is item spot of nums. Add value to total. If value is more than low, set low to value.
The high is total.
Repeat while low is less than high.
The middle is (low plus high) divided by 2. Set limit to middle. Set need to 0. Set used to 0. Set parts to 1. Weigh from 0. If need is at most allowed, set high to middle, otherwise set low to middle plus 1.
Show low.
Expected stdout
18