Question DSA-TP-0074
HardHow do you find the k closest elements to x in a sorted array in O(log n + k)?
- A.
Scan the whole array
- B.
Binary search for x's position, then expand two pointers outward
- C.
Sign up free to see the answer and a step-by-step explanation.