class Solution:
def orderlyQueue(self, S: str, K: int) -> str:
return ''.join(sorted(S)) if K > 1 else min(S[i:] + S[:i] for i in range(len(S)))
leetcode
challenge
Here is the link for the problem:
https://leetcode.com/problems/orderly-queue/description/
Top comments (0)