Code is not working

The string isn’t storing any value as when i print it from the base case nothing is getting printed.
code-https://ide.codingblocks.com/s/323492

hello @amanb25 i have corrected your code please go through it and now code is completely correct.


i hope i have cleared your doubt .
Happy Learning !!

Thank you for the solution, I have one doubt that why do we add the p[j] part to the string shouldn’t it already be added because we are assigning a value to some part of it. For example, suppose we input a string like this-
string s;
for(int i=0; i<5;i++){
cin>>s[i];
}
in this we don’t need to do s+s[i], so why do we do it in the code?

and when i submit this code it still says wrong asnwer.

hello @amanb25 the code is perfectly fine .
your code is passing all the test cases.

1 Like

can you answer this please?

hello @amanb25 sorry for replying late there was some notification problem .
if you still have doubt you can ask here .
otherwise you can mark this doubt as resolved .
on off the chance if you still have doubt you can reopen it and ask again .
Happy Learning !!

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.