ByteByteGo logo
menuProblems List

Sort a K-Sorted Array

Medium

Given an integer array where each element is at most k positions away from its sorted position, sort the array in a non-decreasing order.

Example:

Input: nums = [5, 1, 9, 4, 7, 10], k = 2
Output: [1, 4, 5, 7, 9, 10]

You can practice coding exercises online by logging into bytebytego.com on your laptop.