← Back to Games

🛤️ K-Displacement Lane

Sort Nearly Sorted Array Using Min-Heap of Size K+1

📊 Nearly Sorted Array (Each element at most K positions from sorted)
💡 In a nearly sorted array, each element is at most K positions away from its sorted position. Using a min-heap of size K+1, we can sort it in O(n log K) time.
Min-Heap (Window)
✅ Sorted Output