leetcode solution using java