34.在排序数组中查找元素的第一个和最后一个位置,Java版本解法2注释修改
This commit is contained in:
parent
5d1c088307
commit
7757a60d0e
|
|
@ -223,7 +223,7 @@ class Solution {
|
|||
// 解法2
|
||||
// 1、首先,在 nums 数组中二分查找 target;
|
||||
// 2、如果二分查找失败,则 binarySearch 返回 -1,表明 nums 中没有 target。此时,searchRange 直接返回 {-1, -1};
|
||||
// 3、如果二分查找失败,则 binarySearch 返回 nums 中 为 target 的一个下标。然后,通过左右滑动指针,来找到符合题意的区间
|
||||
// 3、如果二分查找成功,则 binarySearch 返回 nums 中值为 target 的一个下标。然后,通过左右滑动指针,来找到符合题意的区间
|
||||
|
||||
class Solution {
|
||||
public int[] searchRange(int[] nums, int target) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue