SOURCE

let arr = [4,1,2];

let left = arr[0];
let right = arr[arr.length - 1];
let max = 0;
for(let i = 0, j = arr.length - 1; i < j;) {
    console.log("left=>",left);
    console.log("right=>",right);
    if(left < right) {
        i+=1;
        left += arr[i];
        continue;
    }else if(left > right) {
        j-=1;
        right += arr[j];
        continue;
    }else {
        max = max >= left ? max : left;
        // 随便动左边或者右边都行
        i+=1;
        left += arr[i];
    }
}
console.log(max)
console 命令行工具 X clear

                    
>
console