Array Reduction 3 Leetcode Solution