Leetcode OJ Question Java Code