Why am i getting "SIGABRT" error?

question:- CodeChef: Practical coding for everyone
my code:- CodeChef: Practical coding for everyone

logic:: i removed maximum number occuring before 0 in the entire number and if 0 is not there than eliminate the maximum one in the entire number.

Hi @sunil_02! I took a quick look at your solution. There are a couple of things which I think might be causing problems:

  1. int x = int(s[i]) (Line 30) is not the correct way to convert a char to the same int value (and the type conversion method seems to be wrong too). I suggest something like int x = s[i] - '0'. Similarily at other places too.

  2. Please check all the memory accesses too. The index can be wrong at someplace.

  3. Double-check stol(str) and ensure that no invalid input is being given to this function at any point.

Please let me know if this helps.

i used what you have said @apurv but it didn’t work i am still getting error.
is my logic correct??