Not able to do it with string

when i take string , i was not able to print full modified string , it was printing till the previous length of string , pls tell me why it is so and pls do tell cann’t we modify string , for char array it was working perfectly fine …

Hello @Shubham800 you can do this with string as well.
should i share the string code?

hmm pls share string code

@Shubham800 check this:


if you have any doubt in this you can ask here:

pls tell if i want to do with same string , not taking extra memory

https://ide.codingblocks.com/s/417855 here is my string code pls check it !!!

Hello @Shubham800 when you are passing your string pass this as reference so that changes should be reflected.
but this method of yours will not print the correct result because when you are adding at the the null you have to print the string with the help of the indexing:


this code will not pass all the test cases:
you have trade off between the time and space to optimise the code like the code which i have shared in that i am using extra strung named and but for that you are using extra while loop every time so your code is not optmised in case of time even if you have optimised it in the space.

check this as well:

but this method of yours will not print the correct result because when you are adding at the the null you have to print the string with the help of the indexing:

i am not able to understand this thing pls explain it briefly pls

pls check recursion exercise 3rd ques i am getting tle there and i have posted doubt at that too ,my assigned ta is aman yadav,

by this i mean that when you running this loop then you have to ouput the string with the help of the indexing because if you have changed the indexing of the string then by simply doing cout the string will not work:
you have to run the for loop for the size of the string.


check this:

Hello @Shubham800 that assigned TA will help you.
i have no information regarding that doubt of yours.

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.