Two Pointer Approach Leetcode Problems Javascript