Skip to content

Commit 1344863

Browse files
authored
feat: binary-search java solution
Update binary-search.md
2 parents 19c3406 + a37e67d commit 1344863

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

91/binary-search.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,24 @@ def bisect_left(A, x):
544544
return l
545545
```
546546

547+
##### Java
548+
549+
```java
550+
import java.util.*;
551+
public class BinarySearch {
552+
public int getPos(int[] A, int val) {
553+
int low=0,high=A.lenght-1;
554+
while (low <= high){
555+
int mid = (low + high)/2;
556+
if (A[mid] >= val){
557+
high = mid-1;
558+
}else low = mid+1;
559+
}
560+
return low;
561+
}
562+
}
563+
```
564+
547565
其他语言暂时空缺,欢迎
548566
[PR](https://github.com/azl397985856/leetcode-cheat/issues/4)
549567

0 commit comments

Comments
 (0)