Java Practice Questions Leetcode 150