What is SIGSEGV help me out…
@root00198 you are not checking the case when the length of the string is less than 3, in that case, your solution will give runtime error.
To know more about the status codes check here.
The type that s.length() returned when converted to “long” changed into something else(I dont know why, maybe it returns unsigned long). So, when a string of length 1 was given, 1-2 = -1 and in unsigned type it changed into MAX-1 and it ran until that value ultimately getting out of bounds of the string. I typecasted s.length() to “int” and it worked perfectly fine.
Your AC code: https://www.codechef.com/viewsolution/15830879
Hope this helped.
The query is already answered . Moreover I would advise you to use char array instead of string .
You are correct. And it’s easy to verify: link.
The error you are geting is because you are missing a case when string length <3
in that case your solution stumbles and faces runtime error !!!