File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 15
15
public class Solution {
16
16
17
17
/**
18
- * memory function
19
- * store how a word can be decomposed
18
+ * Memory function
19
+ * Store how a word can be decomposed
20
20
*/
21
21
Map <String , List <String >> res = new HashMap <String , List <String >>();
22
22
23
23
/**
24
24
* DP, Backtracking
25
- * Store previous backtracking result in a map
26
- * Generate every substring from front
27
- * If not a word, skip
28
- * If is a word, and if the length run out, add to current solution
25
+ * Store successful decomposition in a map
26
+ * Get prefix
27
+ * If not in dictionary, just ignore
28
+ * If in dictionary, check current position
29
+ * If reaches the end, add prefix to a solution
29
30
* If within length do the following:
30
- * check whether the rest of the string is already broken
31
+ * Check whether the rest of the string is already decomposed
31
32
* If not, backtracking the rest of the string
32
33
* If yes, get the result from memory function
33
34
* If there is an result, add each word to current solution with front in
You can’t perform that action at this time.
0 commit comments