Tricky Permutations

This code is giving run error in two test cases

how to solve this

Hi, please note that the C-style string has an extra null (’\0’) character at the end of the string.
Maximum length of the input can be 8, therefore you need an initial buffer of size 9 (8 + 1).

In case the doubt is resolved, let me know.

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.