Leetcode Problem 1 Solution In Java