Quiz doubts in quesiton

why ans is a?
It should be b na?

next_permutation of(cba) is nothing
it is last permutation so next_permutation return false and also change s to abc hence a is ans

so if we do next permutation on last permutation it will give original number?

Its a cyclic thing, you start at a particular location and if you print 56 (say) times
Then the permutations will repeat
For example:
bca (start)

cba
abc
acb
bac

Upto 56 times

It will iterate as many times you want!

what is 56 times?not getting

Code:

string s=“bca”;
for(int i=0;i<56;i++){
next_permutation(s.begin(), s.end());
cout<<s<<endl;
}

Output:
cab
cba
abc
acb

(56 times)

ok if we do thiss in while loop then it wiill not repeat bbecause it will return false?

Here it very weired options given, the output will have only…
Output:(to original question)
bca cab cba
(Thats it!)
There is error in option itself!

so you mean options are incorrect?

yes
the correct output is :bca cab cba

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.