Leetcode Two Pointer Problems Leetcode Javascript Question