Java solution to leetcode problems.