Two Pointer Technique Leetcode Problems Javascript Array