You are given a string s and a number k.
In each move, you may pick any character from the first k positions of the string and place it at the end of the string.
You can repeat this operation as many times as you want.
Your task is to determine the smallest possible string in lexicographical order that can be formed after performing these moves any number of times.
Input: s = "dbca", k = 1
Output: "acbd"
Explanation:
Only rotations are allowed. The rotation "acbd" is the smallest among all rotations.
Input: s = "zzxy", k = 2
Output: "xyzZ"
Explanation:
Because k > 1, we can freely rearrange characters. Sorted order gives the smallest string.
Accepted:
Submission: