Ma Leetcode Solution Javascript Array