Java Basic Questions Leetcode Two