Two Pointer Questions Leetcode Javascript