leetcode word break II - DFS with memorization