I'm getting NZEC error on the video game problem(ZCO 2014-Contest Page ).
How do i prevent this from happening again?I read a quora answer(https://www.quora.com/What-are-the-various-reasons-that-can-cause-NZEC-errors-on-online-coding-platforms) which was suggested to some other user who had the same problem,I didn't understand a single bit of it,can someone help me figure out the runtime error(NZEC) in the above program and how to i prevent it from happening in the future?
Code:
import java.util.*;public class videogame{public static void main(String args[]){Scanner in = new Scanner(System.in);int n,h,j,x;int i;n=in.nextInt();h=in.nextInt();int heights[] = new int[n];for(i=0;i<n;i++){< pre="">j=in.nextInt();if(j<=h) {heights[i] = j;}else{heights[i]=0;}}int z=0;boolean k = false;while(true){x=in.nextInt();if(x==1){if(z>0){z--;}else{z=0;}}else if(x==2){if(z<n){< pre="">z++;}else{z=n-1;}}else if(x==3&&k==false){if(heights[z]>0) {heights[z]--;k=true;}}else if(x==4&&k==true){if(heights[z]<h){< pre="">heights[z]++;k=false;}}else if(x==0){break;}else{continue;}}for(i=0;i<n;i++){< pre="">System.out.print(heights[i]+" ");}}}