Every element is at most k positions away from where it belongs; sort the array in O(n log k) with a size-k+1 min-heap. Asked in a Rivian senior coding round.
Every element is at most k positions away from where it belongs; sort the array in O(n log k) with a size-k+1 min-heap. Asked in a Rivian senior coding round.
Opens with the full question.