Solved LeetCode program · 777 of 1,000
#1013 · Partition Array Into Three Parts With Equal Sum
Original English source
The numbers is a list of 0, 2, 1, -6, 6, -7, 9, 1, 2, 0, and 1. The total is 0.
For each value in numbers.
Add value to total.
The target is 0. If total modulo 3 is 0, set target to total divided by 3. The valid is 0.
If total modulo 3 is 0.
The running is 0. The finish is the last position of numbers. The cuts is 0.
For every spot from 0 to the last position of numbers.
Increase running by item spot of numbers. If running is target and cuts is less than 2 and spot is less than finish, add 1 to cuts, set running to 0. If spot is finish and cuts is 2 and running is target, set valid to 1.
If valid is 1, show true, otherwise show false.
Expected stdout
true