class Solution {
public:
int getNumberSameAsIndex(vector<int>& nums) {
int n=nums.size();
int l=0,r=n-1;
while(l<r)
{
int mid=l+r>>1;
if(nums[mid]<mid) l=mid+1;
else r=mid;
}
if(nums[l]==l) return l;
else return -1;
}
};
标签:下标,nums,int,数值,数组,69
From: https://www.cnblogs.com/tangxibomb/p/17378281.html