Skip to content

Instantly share code, notes, and snippets.

@Kakarot-2000
Created February 25, 2021 09:57
Show Gist options
  • Save Kakarot-2000/a83517e6fea8b8b628ecee0129f099dd to your computer and use it in GitHub Desktop.
Save Kakarot-2000/a83517e6fea8b8b628ecee0129f099dd 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