Cannot understand the error


#1

I wrote the code on sololearn’s code playground and it’s giving me correct results.
But I’m getting runtime error on interviewbit. It says :
*** Error in `./solution’: free(): invalid next size (fast): 0x0000000000aab0a0 ***
Aborted
Please tell me where I’m going wrong.
here’s my code: