My code is correct. Why am I seeing a runtime error?

When you click Compile and Run, your code is checked against the sample input and sample output by running it against multiple test files that aren’t visible to you. Runtime errors may occur because of the following reasons:

  • Your code does not satisfy all the constraints
  • Your code is not correct for all the possible scenarios

Read the problem statement again, understand it, and write code to solve all the possible scenarios.