Consider a standard binary search algorithm applied to an array nums of unique integers to find a target value target. At each step, a pivot is chosen from the current search range. If the pivot value equals target, the algorithm successfully finds the target. If the pivot value is strictly greater than target, the search space narrows to the elements to the left of the pivot. If the pivot value is strictly smaller than target, the search space narrows to the elements to the right of the pivot.
An element target present in nums is called binary searchable if the binary search algorithm is guaranteed to find it, regardless of which pivot is chosen at each step.
Given an integer array nums, return the number of elements in nums that are binary searchable.
Constraints:
nums.length
nums[i]
All the values of nums are unique.
Consider a standard binary search algorithm applied to an array nums of unique integers to find a target value target. At each step, a pivot is chosen from the current search range. If the pivot value equals target, the algorithm successfully finds the target. If the pivot value is strictly greater than target, the search space narrows to the elements to the left of the pivot. If the pivot value is strictly smaller than target, the search space narrows to the elements to the right of the pivot.
An element target present in nums is called binary searchable if the binary search algorithm is guaranteed to find it, regardless of which pivot is chosen at each step.
Given an integer array nums, return the number of elements in nums that are binary searchable.
Constraints:
nums.length
nums[i]
All the values of nums are unique.