mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Merge pull request #2107 from zou-weidong/patch-1
Update 0034.在排序数组中查找元素的第一个和最后一个位置.md
This commit is contained in:
@ -240,7 +240,7 @@ class Solution {
|
|||||||
while (left - 1 >= 0 && nums[left - 1] == nums[index]) { // 防止数组越界。逻辑短路,两个条件顺序不能换
|
while (left - 1 >= 0 && nums[left - 1] == nums[index]) { // 防止数组越界。逻辑短路,两个条件顺序不能换
|
||||||
left--;
|
left--;
|
||||||
}
|
}
|
||||||
// 向左滑动,找右边界
|
// 向右滑动,找右边界
|
||||||
while (right + 1 < nums.length && nums[right + 1] == nums[index]) { // 防止数组越界。
|
while (right + 1 < nums.length && nums[right + 1] == nums[index]) { // 防止数组越界。
|
||||||
right++;
|
right++;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user