Two Subarrays Leetcode Javascript Solution