auto commit

This commit is contained in:
CyC2018 2020-11-02 01:13:39 +08:00
parent ef625ece95
commit 4e676f4acb
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ l + h 可能出现加法溢出,也就是说加法的结果大于整型能够
```java ```java
public int binarySearch(int[] nums, int key) { public int binarySearch(int[] nums, int key) {
int l = 0, h = nums.length - 1; int l = 0, h = nums.length;
while (l < h) { while (l < h) {
int m = l + (h - l) / 2; int m = l + (h - l) / 2;
if (nums[m] >= key) { if (nums[m] >= key) {

View File

@ -59,7 +59,7 @@ l + h 可能出现加法溢出,也就是说加法的结果大于整型能够
```java ```java
public int binarySearch(int[] nums, int key) { public int binarySearch(int[] nums, int key) {
int l = 0, h = nums.length - 1; int l = 0, h = nums.length;
while (l < h) { while (l < h) {
int m = l + (h - l) / 2; int m = l + (h - l) / 2;
if (nums[m] >= key) { if (nums[m] >= key) {