Linkage
https://leetcode.com/problems/word-break/description/
https://leetcode.com/problems/word-break-ii/description/
Analysis
In the first question, we just need to count the combination of wordBreak, but in the second question, we need to find out all the combination. To avoid TLE crisis because of a tricky case in Word Break II, we need to judge the first in advance.
Question I: Word Break
1 | class Solution { |
Question II: Word Break II
Naive code
1 | class Solution { |
To pass a very tricky but unmeaningful false case, we should judge whether there is a path prior to find path.
1 | class Solution { |
So ugly!!!