Two Subarrays Leetcode Javascript Problems