Java implementation for LeetCode problems