Maximum Sum Value Leetcode Javascript Question