Two Pointers Leetcode Javascript Solution