Different results when running same test case as custom input and when submitting

The test case passed when putting as custom input. But getting the following error when submitting:
*** Error in `./solution’: free(): invalid next size (fast): 0x0000000000e2b290 ***
Aborted

Click here to start solving coding interview questions