https://oj.leetcode.com/discuss/14723/my-accepted-dfs-java-solution