File tree 1 file changed +39
-2
lines changed 1 file changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## All break
1
2
2
- ## TODO
3
- * write down thinking
3
+ Brute force is my favourite. However, ` 2 ^ n ` seems a huge number.
4
4
5
+
6
+ ## Something like [ Jump Game II] ( ../jump-game-ii )
7
+
8
+ That ` s[0..i] ` can be ` break ` indicates ` s[i + each d in dict] ` can be ` break ` .
9
+
10
+ Make a table ` P ` , such that, ` P[i] ` means if ` s[0..i] ` can be ` break ` .
11
+
12
+ ```
13
+ dict { leet, code }
14
+
15
+ Table:
16
+
17
+ 0 1 2 3 4 5 6 7 8 Index
18
+ * l e e t c o d e
19
+ 1 0 0 0 1 0 0 0 1
20
+
21
+ ```
22
+
23
+ Calculating ` P[i] `
24
+
25
+ ```
26
+ dict { leet, code }
27
+
28
+ Table:
29
+
30
+ 0 1 2 3 4 5 6 7 8 Index
31
+ * l e e t c o d e
32
+ 1 0 0 0 1 ? ? ? ?
33
+ ^
34
+ i
35
+ ```
36
+
37
+ here if ` P[i] ` wants to be true, either ` s[0..i] ` ` (leetc) ` or ` s[4..i] ` ` (c) ` must be in the dict.
38
+
39
+ So,
40
+
41
+ ` P[i] = P[0..j] && s[j..i] in dict, j = 0..i `
You can’t perform that action at this time.
0 commit comments