1966. Binary Searchable Numbers in an Unsorted Array
Description
func(sequence, target)
while sequence is not empty
**randomly** choose an element from sequence as the pivot
if pivot = target, return **true**
else if pivot < target, remove pivot and all elements to its left from the sequence
else, remove pivot and all elements to its right from the sequence
end while
return **false****Input:** nums = [7]
**Output:** 1
**Explanation**:
Searching for value 7 is guaranteed to be found.
Since the sequence has only one element, 7 will be chosen as the pivot. Because the pivot equals the target, the function will return true.ac
Previous1965. Employees With Missing InformationNext1967. Number of Strings That Appear as Substrings in Word
Last updated