Two Pointer Approach Leetcode Javascript Solution