Question DSA-ARR-0072
HardIn an array where each element is at most k positions from its sorted place, how fast can you sort it?
- A.
O(k)
- B.
O(n log n) only
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Arrays question
In an array where each element is at most k positions from its sorted place, how fast can you sort it?
O(k)
O(n log n) only
Sign up free to see the answer and a step-by-step explanation.
O(n²)
O(n log k) with a min-heap of size k + 1