Java 1D Array (Part 2)

  • + 1 comment

    I've made a correction in my code and the output for ibexxx's input is 'YES'.I just exchanged the first if statement and the else if statement following it. Yet the 5 testcases fail. I changed these lines

    if(i+leap<=n-1 && game[i+leap]==0 && leap!=0) i=i+leap;
                else if(i+1<=n-1 && game[i+1]==0) i=i+1;
    

    which makes jumps of 4,4,4 to

    if(i+1<=n-1 && game[i+1]==0) i=i+1;
    else if(i+leap<=n-1 && game[i+leap]==0 && leap!=0) i=i+leap;
    

    which makes jumps of 1,1,4,4,4.

    • + 0 comments

      Now your code fails on:

      1
      16 4
      0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 1