Doubt doubt doubt

Q10. Algorithms STL#10

Given the following code snippet :

string s = “bca”;

do {

    cout << s << ' ';
} while(next_permutation(s.begin(), s.end()));

cout << s;

What is the output of the given code?

Please explain the output of the 10 questions.

For me, it should be:

-> bca cab cba -> while loop ends --> cba

hello @parth_tyagi

output should be abc.
becuase
bca cab cba-> after this one more that next perm will be called and becuase next greater perm doesnt exist it will return false and it modify the given string to smallest perm possible which is abc.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.