代码重构 【Github Actions】

This commit is contained in:
github-actions[bot]
2021-07-26 16:17:05 +00:00
parent 94d9b4c70f
commit d0abf3e1d8
7 changed files with 11 additions and 10 deletions

View File

@@ -140,7 +140,6 @@ func binarySearch(nums []int, target, left, right int) int {
}
```
二分查找的思路及代码已经理解了那么我们来看一下实现时容易出错的地方
1.计算 mid 不能使用 left + right / 2,否则有可能会导致溢出
@@ -157,7 +156,7 @@ Java Code:
```java
public static int binarySearch(int[] nums,int target,int left, int right) {
if (left <= right) {
int mid = left + ((right - left) >> 1);
if (nums[mid] == target) {