Skip to content

Commit b14d98a

Browse files
committed
增加No5416
1 parent 450649f commit b14d98a

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

.idea/workspace.xml

Lines changed: 29 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

String/No5416.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package String;
2+
3+
/**
4+
* @author tujietg
5+
* @date 5/24/20 3:56 PM
6+
*/
7+
public class No5416 {
8+
9+
public int isPrefixOfWord(String sentence, String searchWord) {
10+
int endIndex = -1;
11+
String[] s = sentence.split(" ");
12+
for (int i = 0; i < s.length; i++) {
13+
if (s[i].startsWith(searchWord)) {
14+
return i + 1;
15+
}
16+
}
17+
return -1;
18+
}
19+
}

0 commit comments

Comments
 (0)