Two Subarrays Leetcode Javascript Question