import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class HackerRankJumpingClouds {
    static int jumpingOnClouds(int[] c) {
        int steps = 0;
        List<Integer> clouds = new ArrayList<>();
        for(int index: c) {
            clouds.add(index);
        }
        System.out.println("Clouds: " + clouds);

        List<Integer> avoidIndexes = new ArrayList<>();
        for(int index: clouds) {
            if (index == 1) {
                avoidIndexes.add(index);
            }
        }
        System.out.println("Clouds to avoid: " + avoidIndexes.size());

        boolean jumped2Steps = false;
        for (int i=0; i<clouds.size()-1; i++) {
            if(jumped2Steps) {
                jumped2Steps=false;
                System.out.println("Do nothing. Stepped 2 steps previous time, so do nothing for index " + i);
            } else {
                if ((i<clouds.size()-2) && (clouds.get(i+2)==0)) {
                    steps++;
                    jumped2Steps=true;
                    System.out.println("Stepping 2 steps from: " + i);
                } else if (clouds.get(i+1) == 0) {
                    steps++;
                    jumped2Steps=false;
                    System.out.println("Stepping one step from: " + i);
                }
            }

        }

        System.out.println("Steps: " + steps);
        return steps;
    }

    public static void main (String[] args) {
        //Current cloud plus 1 or 2!

        int[] clouds1 = {0,0,0,0,1,0}; //Avoid 4 => 0-1-3-5 or 0-2-3-5 => 3 jumps

        int[] clouds2 = {0,0,1,0,0,1,0};//Avoid 2 and 5 => Minimum 0-1-3-4-6 =>4 jumps

        int[] clouds3 = {0,0,0,1,0,0}; //Avoid 3 => Minimum 0-2-4-5 => => 3 jumps
        jumpingOnClouds(clouds1);

    }
}
