Jumping on the Clouds: Revisited

  • + 0 comments

    Java:

        static int jumpingOnClouds(int[] c, int k) {
            int e = 100;
            int pos = 0;
            
            do {
                pos = (pos + k) % c.length;
                e -= 1 + 2 * c[pos];
            } while (pos != 0);
            
            return e;
        }