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

Commit1aceb60

Browse files
committed
Ip ADDRESS
1 parent0e5ae7d commit1aceb60

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎string/RestoreIpAddresses.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public List<String> restoreIpAddresses(String s) {
1919

2020
publicvoiddfs(Strings,intindex,ArrayList<String>path,ArrayList<String>ret) {
2121
if (path.size() ==4) {
22-
if (index ==s.length() &&path.size() ==4) {
22+
if (index ==s.length()) {
2323
StringBuildersb =newStringBuilder();
2424
for (Stringstr:path) {
2525
sb.append(str);
@@ -35,12 +35,13 @@ public void dfs(String s, int index, ArrayList<String> path, ArrayList<String> r
3535

3636
intlen =s.length();
3737
for (inti =index;i <index +3 &&i <len;i++) {
38+
// 不可以有005这样子的IP地址。
3839
if (s.charAt(index) =='0' &&i >index) {
3940
break;
4041
}
4142

4243
Stringpre =s.substring(index,i +1);
43-
//过滤Number > 255的情况。
44+
//过滤num > 255的情况。
4445
intnum =Integer.parseInt(pre);
4546
if (num >255) {
4647
continue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp