We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
const search = (nums, target) => { let [left, right] = [0, nums.length - 1]; while (left <= right) { const mid = (left + right) >> 1; if (nums[mid] === target) return mid; if (nums[left] < nums[mid]) { // 左边是升序区间 if (nums[left] <= target && target <= nums[mid]) { // 目标值在升序区间内 right = mid - 1; } else { // 目标值不在升序区间内 left = mid + 1; } } else { // 右边是升序区间 if (nums[mid] <= target && target <= nums[right]) { // 目标值在升序区间内 left = mid + 1; } else { // 目标值不在升序区间内 right = mid - 1; } } } return nums[left + 1] === target ? left + 1 : -1; };
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: