Java Basic Questions Leetcode Javascript Solution