Error in `./solution': double free or corruption (out)

I am not sure of this error. It shows the correct result on “Test with custom output” but fails in test

Click here to start solving coding interview questions