• + 0 comments

    java 8

    public static int jumpingOnClouds(List<Integer> c) {
        // Write your code here
        int jump = 0;
        int start = 0;
    
        while (start < c.size() - 1) {
            if (start == c.size() - 2) {
                jump++;
                break;
    
            }
            int idx = (c.get(start + 2) != 0) ? 1 : 2;
            start += idx;
            jump++;
    
        }
        return jump;