You are viewing a single comment's thread. Return to all comments →
can you please tell me for which input it is giving wrong answer?
string biggerIsGreater(string w) { bool avail=false; for(int i=w.length()-1; i>=0; i--){ for(int j = i-1; j>=0; j--){ if(w[j]<w[i]){ avail=true; swap(w[j], w[i]); string ans=w.substr(j+1); sort(ans.begin(), ans.end()); return w.substr(0, j+1) + ans; } } } if(avail==false){ return "no answer"; }else{ return ""; } }
Bigger is Greater
You are viewing a single comment's thread. Return to all comments →
can you please tell me for which input it is giving wrong answer?