二分
Data Structures & Algorithms · 11 notes
- Binary Search Upper Boundhistorical
Implement binary search on an ascending array that may contain duplicate values. Return the position of the first value greater than or equal to the target.
- Find First and Last Position of Element in Sorted Arrayhistorical
Given an integer array nums sorted in ascending order and a target value target, find the starting and ending positions of the target value in the array.
- Binary Search Upper Boundhistorical
Implement binary search on an ascending array that may contain duplicate values. Return the position of the first value greater than or equal to the target.
- Find First and Last Position of Element in Sorted Arrayhistorical
Given an integer array nums sorted in ascending order and a target value target, find the starting and ending positions of the target value in the array.
- Search in Rotated Sorted Arrayhistorical
Given a rotated sorted array whose rotation count is unknown in advance (for example, 0 1 2 4 5 6 7 may become 4 5 6 7 0 1 2). Search for the given target value in the array.
- Search in Rotated Sorted Arrayhistorical
Given a rotated sorted array whose rotation count is unknown in advance (for example, 0 1 2 4 5 6 7 may become 4 5 6 7 0 1 2). Search for the given target value in the array.
- Find Peak Elementhistorical
A peak element is strictly greater than its neighbors. Find a peak in the given array and return its index.
- Binary Searchhistorical
Given an n-element sorted (ascending) integer array nums and a target value target, write a function to search for target in nums. If the target exists, return its index; otherwise return -1.
- Find Minimum in Rotated Sorted Arrayhistorical
Given a rotated ascending array, find its minimum element.
- Square Roothistorical
Implement the function int sqrt(int x). Compute and return the square root of x, rounded down.
- Find Smallest Letter Greater Than Targethistorical
Given a sorted list of characters letters containing only lowercase English letters, and a target letter target, find the smallest letter in this ordered list that is greater than the target letter.