Java Soluction for LeetCode