Skip to content

Commit e876e05

Browse files
author
liwentian
committed
fd
1 parent f99005e commit e876e05

File tree

66 files changed

+198
-1043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+198
-1043
lines changed

ebook/Backtracking.tex

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,38 @@ \subsubsection{Description}
12851285
\subsubsection{Solution}
12861286

12871287
\begin{Code}
1288+
/**
1289+
* 注意,0可以,但是00,01, 010这种是不允许的
1290+
*/
1291+
public List<String> restoreIpAddresses(String s) {
1292+
List<String> list = new LinkedList<>();
1293+
dfs(s, list, 0, 0, "");
1294+
return list;
1295+
}
1296+
1297+
private void dfs(String s, List<String> list, int index, int count, String cur) {
1298+
if (index >= s.length()) {
1299+
if (count == 4) {
1300+
list.add(cur);
1301+
}
1302+
return;
1303+
}
1304+
1305+
if (count == 4) {
1306+
return;
1307+
}
12881308

1309+
int[][] RANGES = {
1310+
{0, 0}, {0, 9}, {10, 99}, {100, 255}
1311+
};
1312+
for (int i = 1; i <= 3 && index + i <= s.length(); i++) {
1313+
String t = s.substring(index, index + i);
1314+
int n = Integer.parseInt(t);
1315+
if (n >= RANGES[i][0] && n <= RANGES[i][1]) {
1316+
dfs(s, list, index + i, count + 1, (cur.isEmpty() ? "" : cur + ".") + t);
1317+
}
1318+
}
1319+
}
12891320
\end{Code}
12901321

12911322
\newpage

ebook/leetcode.log

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex 2017.9.4) 5 SEP 2017 22:19
1+
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex 2017.9.4) 6 SEP 2017 09:21
22
entering extended mode
33
restricted \write18 enabled.
44
%&-line parsing enabled.
@@ -1969,7 +1969,7 @@ File: images/watch.jpg Graphic file (type QTm)
19691969
.
19701970
\FV@Error ...ncyVerb Error:^^J\space \space #1^^J}
19711971

1972-
l.2235 \end{Code}
1972+
l.2266 \end{Code}
19731973

19741974
This error message was generated by an \errmessage
19751975
command, so I can't give any explicit help.
@@ -1982,7 +1982,7 @@ and deduce the truth by order and method.
19821982
.
19831983
\FV@Error ...ncyVerb Error:^^J\space \space #1^^J}
19841984

1985-
l.2269 \end{Code}
1985+
l.2300 \end{Code}
19861986

19871987
(That was another \errmessage.)
19881988

@@ -1994,7 +1994,7 @@ File: images/unlock.png Graphic file (type QTm)
19941994
.
19951995
\FV@Error ...ncyVerb Error:^^J\space \space #1^^J}
19961996

1997-
l.2369 \end{Code}
1997+
l.2400 \end{Code}
19981998

19991999
(That was another \errmessage.)
20002000

ebook/leetcode.pdf

1.4 KB
Binary file not shown.

ebook/leetcode.synctex.gz

2.28 KB
Binary file not shown.

solution/src/main/java/com/inuker/solution/AverageOfLevelsInBinaryTree.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.inuker.solution;
22

3+
import com.leetcode.library.TreeNode;
4+
35
import java.util.LinkedList;
46
import java.util.List;
57
import java.util.Queue;

solution/src/main/java/com/inuker/solution/BSTIterator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.inuker.solution;
22

3+
import com.leetcode.library.TreeNode;
4+
35
import java.util.Stack;
46

57
/**

solution/src/main/java/com/inuker/solution/BalancedBinaryTree.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Created by dingjikerbo on 2016/11/28.
55
*/
66

7+
import com.leetcode.library.TreeNode;
8+
79
/**
810
* 平衡二叉树条件是左边是平衡,右边是平衡,且两边高度差相差不超过1
911
* 树的高度是所有子树的最大高度

solution/src/main/java/com/inuker/solution/BinaryTreeInorderTraversal.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.inuker.solution;
22

3+
import com.leetcode.library.TreeNode;
4+
35
import java.util.LinkedList;
46
import java.util.List;
57
import java.util.Stack;

solution/src/main/java/com/inuker/solution/BinaryTreeLevelOrderTraversal.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.inuker.solution;
22

3+
import com.leetcode.library.TreeNode;
4+
35
import java.util.LinkedList;
46
import java.util.List;
57
import java.util.Queue;

solution/src/main/java/com/inuker/solution/BinaryTreeLevelOrderTraversalII.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.inuker.solution;
22

3+
import com.leetcode.library.TreeNode;
4+
35
import java.util.LinkedList;
46
import java.util.List;
57
import java.util.Queue;

0 commit comments

Comments
 (0)