Next Permutation, TC not getting passed

Please check the logic and the implementation part, my code fails in all the test cases. Can u provide the test case where it fails?

for input :
6 1 8 8
ur o/p
61998
required
6 8 1 8

also please add space after each character

Hello Chhavi, thanks for clearing it out, I am still not able pass TC 4 what might be the error? Please can u find it out.

please share updated code

Updated code: https://ide.codingblocks.com/s/224008

refer to this
ur code is having run time for some case

Hello Chhavi, thanks for that code, I found the error it was

2 8 8 or similar cases where iterator goes till 0. Thanks for reply

1 Like