*** Error in `./solution': double free or corruption (out): 0x0000000002272010 *** Aborted

When I try to test or submit my code, i get this error, although it works perfectly fine on custom input test.
Lost so many points due to this.

In my code it was happening for descending order input. Some part of the code was unnecessarily executing and modifying the vector which was causing memory error . Finally i used flag to conditionally execute that portion.

In my case I was not returning(adding return) inside the if(i == 0) case and code proceeded with the statement A[i - 1] for inputs where all elements are in descending order. The test case shown by the compiler is different from which the one throwing this error.

Click here to start solving coding interview questions