Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
We want to make the smaller digits the most significant digits in the number.
For each index i, check the smallest digit in a window of size k and append it to the answer. Update the indices of all digits in this range accordingly.