Skip to content

Commit 7525bd9

Browse files
committed
899
1 parent 05dfaee commit 7525bd9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

String/899.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Orderly Queue
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/orderly-queue/)
6+
7+
---
8+
9+
#### Solution
10+
11+
- See Code
12+
13+
---
14+
15+
#### Code
16+
17+
O(nlogn)
18+
19+
```python
20+
class Solution:
21+
def orderlyQueue(self, S: str, K: int) -> str:
22+
return "".join(sorted(S)) if K > 1 else min(S[i:] + S[:i] for i in range(len(S)))
23+
```

0 commit comments

Comments
 (0)