You are viewing a single comment's thread. Return to all comments →
My Java solution:
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int c[] = new int[n]; for(int i=0; i < n; i++){ c[i] = in.nextInt(); } int count = -1; for (int i = 0; i < n; i++, count++) { if (i<n-2 && c[i+2]==0) i++; } System.out.println(count); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Jumping on the Clouds
You are viewing a single comment's thread. Return to all comments →
My Java solution: