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

Commitd4cd4cf

Browse files
authored
Update Binary Search.java
1 parentdd8dd65 commitd4cd4cf

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

‎Easy/Binary Search.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
classSolution {
22
publicintsearch(int[]nums,inttarget) {
3-
intleft =0;
4-
intright =nums.length -1;
5-
while (left <=right) {
6-
intmid = (left +right) /2;
3+
intstart =0;
4+
intend =nums.length -1;
5+
while (start <=end) {
6+
intmid = (start +end) /2;
77
if (nums[mid] ==target) {
88
returnmid;
9-
}
10-
elseif (nums[mid] >target) {
11-
right =mid -1;
12-
}
13-
else {
14-
left =mid +1;
9+
}elseif (nums[mid] <target) {
10+
start =mid +1;
11+
}else {
12+
end =mid -1;
1513
}
1614
}
1715
return -1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp