Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 318 Bytes

899.md

File metadata and controls

23 lines (14 loc) · 318 Bytes

Orderly Queue

Description

link


Solution

  • See Code

Code

O(nlogn)

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)))