Two Pointer Problems Leetcode Javascript Solution