leetcode solution by java