Jumping on the Clouds: Revisited

  • + 0 comments
        static int jumpingOnClouds(int[] c, int k) {
            int e = 100;
            int i = 0;
            do {
                if (c[i] == 0) {
                    e -= 1;
                } else if (c[i] == 1) {
                    e -= 3;
                }
                i = (i+k) % c.length;
            } while (i != 0);
            return e;
        }