Cannot understand the error

https://ide.codingblocks.com/s/349916 - What is the error in my coe?


I corrected your code. Please check it.

Sir, I don’t want to take any other string. Please tell me why my code gives error or what is the meaning of this error?

Taking a different string is convenient and easy. Its not advisable at all to make changes to the same original string or data in any question.

But if I take an extra string, then my space complexity maybe high. Please clarify

Complexity is same O(n) only. And you will have to input the string atleast, so it doesn’t matter. Plus while making changes to the original string, it becomes very complex to keep track of the pointer i as size of the string changes.

But sir, if I don’t take any extra string, then I think space complexity is O(1). Is it correct?

No the space complexity will still be O(n). This is because for input you need one string atleast.

OK sir. But what is the meaning of the error?

What error were you getting?

Sir, please run my code.

In line 7 you are returning a character. And the return type of your function is string.

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.