• + 0 comments
    public static int jumpingOnClouds(List<Integer> c) {
    // Write your code here
    

    int jumps = 0; int i = 0;

    while (i < c.size() - 1) {
        // Prefer jumping 2 steps if possible, otherwise jump 1 step
        if (i + 2 < c.size() && c.get(i + 2) == 0) {
            i += 2;
        } else {
            i += 1;
        }
        jumps++; // Count the jump
    }
    
    return jumps;
    }