I tried couple of times in c, but it seems to throw runtime error, then coded the same solution in c++ that resulted in correct answer. The editorial solution of c language also results in runtime error. I hope you fix that as soon as possible
Yes. There is a problem with the C implementation. Getting a runtime error for any solution, including the ones given in the Complete Solution for C language.