I guess my logic is correct could u tell me the mistake in the code its not running

hello @anantgovil123 you just have to write return in the base case .
then your function will work fine .
if you still feel that your doubt is not cleared please ask here i will explain .
Happy Learning !!

https://ide.codingblocks.com/s/346166 i did that still last o is not printing now sir

this is because you are trying to inplace .
you have to take extra space and then you will be able to do in the correct manner .