Skip to content

Instantly share code, notes, and snippets.

@Kakarot-2000
Created February 25, 2021 10:01
Show Gist options
  • Save Kakarot-2000/f1b49c9f167f27480aa289b2d4707f55 to your computer and use it in GitHub Desktop.
Save Kakarot-2000/f1b49c9f167f27480aa289b2d4707f55 to your computer and use it in GitHub Desktop.
string fun1(string s,int k){
if(k>1){
sort(s.begin(),s.end());
return s;
}
string res=s;
for(int i=0;i<s.length();i++){
char ch=s[0];
s.erase(s.begin(),s.begin()+1);
s+=ch;
if(s<res) res=s;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment