30 Days of Code [Day 16]
QUESTION : 899. Orderly Queue
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define fo(i,s,n) for(int i=s;i<n;++i)
#define of(i,s,n) for(int i=s-1;i>=n;--i)
#define fv(V) for( auto &it : V )
class Solution {
public:
string orderlyQueue(string s, int k) {
if(k > 1) {
sort(all(s));
return s;
}
string res = s;
fo(i,1,s.length()) res = min(res, s.substr(i) + s.substr(0,i));
return res;
}
};