Two Pointer Approach Leetcode Javascript Question