• + 0 comments

    public static int jumpingOnClouds(List c) { //narayan gupta int jumps = 0; int i = 0; while (i < c.size() - 1) { if (i + 2 < c.size() && c.get(i + 2) == 0) { i += 2; // Jump 2 clouds if possible } else { i += 1; // Otherwise, jump 1 cloud } jumps++; // Count each jump } return jumps;
    }