Two Pointer Leetcode Problems Java