diff --git a/docs/notes/Leetcode 题解 - 二分查找.md b/docs/notes/Leetcode 题解 - 二分查找.md index f00a100f..e3abd548 100644 --- a/docs/notes/Leetcode 题解 - 二分查找.md +++ b/docs/notes/Leetcode 题解 - 二分查找.md @@ -59,7 +59,7 @@ l + h 可能出现加法溢出,也就是说加法的结果大于整型能够 ```java public int binarySearch(int[] nums, int key) { - int l = 0, h = nums.length - 1; + int l = 0, h = nums.length; while (l < h) { int m = l + (h - l) / 2; if (nums[m] >= key) { diff --git a/notes/Leetcode 题解 - 二分查找.md b/notes/Leetcode 题解 - 二分查找.md index f00a100f..e3abd548 100644 --- a/notes/Leetcode 题解 - 二分查找.md +++ b/notes/Leetcode 题解 - 二分查找.md @@ -59,7 +59,7 @@ l + h 可能出现加法溢出,也就是说加法的结果大于整型能够 ```java public int binarySearch(int[] nums, int key) { - int l = 0, h = nums.length - 1; + int l = 0, h = nums.length; while (l < h) { int m = l + (h - l) / 2; if (nums[m] >= key) {