Jumping on the Clouds: Revisited

  • + 0 comments

    static int jumpingOnClouds(int[] c, int k) { int en = 0; int i = 0; while((i+k)%c.length != 0){ en++; if(c[i%c.length] == 1){ en = en+2 ;

            }
            i=i+k ;
        }
        if(c[c.length-k] == 1 ) en = en+2;
        en++;
        return 100-en;
    }