problem from leetcodeoj by using Java