http://www.nxcoding.com/archives/leetcode-daily-2140-solving-intelligence-questions-dfs-memoization