Algorithm · xAI · Hard
Requirements For the warm-up, implement a function that returns the k-th smallest or k-th largest item in an array: The order argument specifies whether the ranking is from the smallest side or the largest side. Examples Input: Output: The sorted values are [2, 3, 5, 8, 11], so the second-smallest value is 3. Input: Output: Reading from largest to smallest gives [9, 6, 4, 1], making 6 the second-largest value. Follow-up Now assume values arrive continuously as (timestamp,…
Checking your access…