Java solution for all leetcode problems