blob: 23053d2ee1ef6ecd9b13f4daa12d39deb47a739c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "leetcode.h"
class Solution {
public:
string orderlyQueue(string s, int k) {
if (k > 1) {
sort(s.begin(), s.end());
return s;
}
string ans = s;
for (int i = 1; i < s.size(); i++)
ans = min(ans, s.substr(i) + s.substr(0, i));
return ans;
}
};
int main() {
Solution obj;
cout << obj.orderlyQueue("cba", 1);
}
|