Two Subarrays Leetcode Javascript Questions