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

Commitac30da0

Browse files
Jian GUfishercoder1534
Jian GU
authored andcommitted
Update _35.java (#36)
1 parenta608a97 commitac30da0

File tree

1 file changed

+6
-16
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+6
-16
lines changed

‎src/main/java/com/fishercoder/solutions/_35.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,14 @@
1818

1919
publicclass_35 {
2020

21-
publicintsearchInsert(int[]A,inttarget) {
22-
intlen =A.length;
23-
if (len ==0) {
24-
return0;
25-
}else {
26-
for (inti =0;i <len;i++) {
27-
if (A[0] >target) {
28-
return0;
29-
}elseif (A[len -1] <target) {
30-
returnlen;
31-
}elseif (A[i] ==target) {
32-
returni;
33-
}elseif (A[i] <target &&A[i +1] >target) {
34-
returni +1;
35-
}
21+
publicintsearchInsert(int[]nums,inttarget) {
22+
intlen =nums.length;
23+
for (inti =0;i <len;i++) {
24+
if (target <=nums[i]) {
25+
returni;
3626
}
37-
returnlen;
3827
}
28+
returnlen;
3929
}
4030

4131
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp