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

Commitef9cb6a

Browse files
Ben MakushaBen Makusha
Ben Makusha
authored and
Ben Makusha
committed
Create 0028-find-the-index-of-the-first-occurence-in-a-string
1 parent94bbd8b commitef9cb6a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
classSolution {
2+
publicintstrStr(Stringhaystack,Stringneedle) {
3+
intresult =0;
4+
if (haystack.length() <=0 &&needle.length() >0)return -1;
5+
if (haystack.length() !=0) {
6+
intoccurence =haystack.indexOf(needle);
7+
if (occurence == -1)
8+
returnoccurence;
9+
result =occurence;
10+
}
11+
returnresult;
12+
}
13+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp