#include
#include
#include
using namespace std;
bool compare(string s1,string s2){
return s1<s2;
}
void permute(string ip,int i,string a,int &k,string arr[]){
sort (arr,arr+k);
if(ip[i]=='\0'){
if(ip<a){
arr[k]=ip;
k++;
}
}
for(int j=i;j<ip.length();j++){
swap(ip[i],ip[j]);
permute(ip,i+1,a,k,arr);
swap(ip[i],ip[j]);
}
}
int main() {
string ip;
cin>>ip;
string a;
a=ip;
string arr[1000];
int k=0;
permute(ip,0,a,k,arr);
sort(arr,arr+k,compare);
for(int i=0;i<k;i++){
cout<<arr[i]<<endl;
}
return 0;
}
why this code is not passing all the tst cases its giving me tle in some test cases