Java Practice Questions Leetcode Problem