Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb546556

Browse files
committed
add word break ii
1 parent2a6e557 commitb546556

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

‎word-break-ii/README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
1+
##[Word Break](../word-break) with traceback
2+
3+
In order to output all solutions,
4+
just change P from`boolean` to a collection which contains all parent index.
5+
6+
7+
```
8+
0 1 2 3 4 5 6 7 8 9 A
9+
* c a t s a n d d o g
10+
11+
0 0 3 7
12+
4
13+
14+
15+
P[3] = [0]
16+
P[4] = [0]
17+
18+
P[7] = [3, 4]
19+
P[10] = [7]
20+
21+
```
22+
23+
##Recover strings using DFS
24+
25+
To find all strings break at breakpoint, just using DFS to find out them.
26+
27+
* 10, 7, 3, 0: dog sand cat
28+
* 10, 7, 4, 0: dog and cats
29+
30+
###Note:
31+
32+
offsets here is 1 larger than the original offset.
33+
34+
So,`7..10` here is to start form the next element, the 8th to the 11th(exclusive).
35+
36+
Luckily, restore the`S[8th..11th]` is just the same as`S[7..10]`,
37+
Because index of S starts from`0`.
138

2-
##TODO
3-
* write down thinking
439

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp