Jumping on the Clouds
February 2, 2021
Problem
Solution
import java.io.IOException; public class JumpingOnClouds { static int jumpingOnClouds(int[] c) { int jumps = 0; for (int i = 0; i < c.length; ) { if (i + 2 < c.length && c[i + 2] == 0) i += 2; else i++; jumps++; } return jumps - 1; } public static void main(String[] args) throws IOException { int[] c = {0, 0, 1, 0, 0, 1, 0}; int result = jumpingOnClouds(c); System.out.println(result); } }