code is getting compiled but not getting any output
Move all x to end
@Megha2468 The strings in C++ STL are not null terminated.
So better use char arr[] and then try doing this.
corrected that but not getting x at the end
It is because here the n value is not actual size of input, it is the default initialized size.
so better use strlen() for finding the value of n here.
Also in base case, dont terminate out[j] with null char, because it is not the last index for your output string because you are also moving the index in opposite direction from n-> n-1 -> n-2 and so on…
I hope you have got it.
If you are facing any issue in implementation then only you can refer to this corrected code https://ide.codingblocks.com/s/217547
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.