My leetcode java solution