Runtime error in 2 test case

could you please help me identify where am i doing wrong? i guess i coded it right

Runtime error can occur due to following reasons:

  1. Invalid memory access during run-time.
  2. Accessing linked list nodes that do not exist.
  3. Dividing by zero.
  4. Large allocation of memory together/Large Static Memory Allocation.
  5. Making a silly mistake.

The input array can be larger than 1000 elements.
Thus, do the following changes:
int n;
cin>>n;
int a[n];

Hope this would help.
Give a like, if you are satisfied.

1 Like