Segmentation faults replace with pi

@Vikaspal


check this
eaasy logic
u are not checking for out of bound
always check i +1 < size

@chhavibansal actually i doing it recursively inplace i am dry this on xpix and when i reach to NULL means n i am returning from there …

but then
image
yeh chese agar size 2 hua to u are trying to access out of bound

first try to use extra string then try to optimise (inplace)

@chhavibansal esme agr hum i+1 check nhi kare then it should work because if we reaches to null then we are going to return from there.

u need to check if (a[i+1] != ‘\0’ ) either at line 6 or line 9
verna u will try to access invalid memory location


can u please checkout this. here after dry run this code i am not able to find a case there memory access is invalid.

define inp for each test case
image

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.