When i submit my solution in C++, for the input: 2 4 0 0 0 0 0 0 1 1
the compiler reports this Runtime Error:
*** Error in `./solution’: double free or corruption (out): 0x0000000000e8c150 ***
Where as, on running the same case as custom input, it returns the expected solution just fine.
If any one can explain what is happening, the help is appreciated.