What exactly is SIGABRT? How do I fix this, the code is runnning fine when I use g++ on my own computer. It seems like its passing all the test cases for PALIN though. Here is code: https://ideone.com/jtV8Zq and another maybe cleaner version: https://ideone.com/5yhbwb
Ok well… I fixed it. Not exactly sure what is wrong, but I created my own addOne() function to prevent modifying strings to ints and back to string to do the addition. If someone could point out to me why that gives SIgABRT that would be nice. Also, heres the fixed code if someone was wondering: https://ideone.com/9XdW2J
Try your original code with this test case
1 123456789012345678901234567890123456789012345678901234567890
I think calling stoi is the problem.
Question states: “For a given positive integer K of not more than 1000000 digits”. That was why I was using stoi to convert to int because then it would’t overflow.
If you run your code with that test case, what is it that you’re passing to stoi? It’s “123456789012345678901234567890” - how is that not going to overflow when converting to an int?
Yea, but isn’t it bounded by like 10^6 so in theory it shouldn’t even be testing inputs that large, so we wouldn’t run into overflow.
Read that bit again… digits.
Ohhhhhhh, okeyyyy got it I am retarded.
We sometimes see what we expect to see, and not what is actually there.