Skip to content

Commit

Permalink
Update binary-search.md
Browse files Browse the repository at this point in the history
Java
增加Java版本的二分变种--最左插入位置
  • Loading branch information
doublehearts authored Sep 13, 2022
1 parent 19c3406 commit a37e67d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 91/binary-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,24 @@ def bisect_left(A, x):
return l
```

##### Java

```java
import java.util.*;
public class BinarySearch {
public int getPos(int[] A, int val) {
int low=0,high=A.lenght-1;
while (low <= high){
int mid = (low + high)/2;
if (A[mid] >= val){
high = mid-1;
}else low = mid+1;
}
return low;
}
}
```

其他语言暂时空缺,欢迎
[PR](https://github.com/azl397985856/leetcode-cheat/issues/4)

Expand Down

0 comments on commit a37e67d

Please sign in to comment.