package Codility;

//light bulb
public class LightBulbs {
    public static void main(String[] args) {
        int[] A = {2, 1, 3, 5, 4};
        int count = 0;
        int numComparison = 0;
        for (int i = 0; i < A.length; i++) {
            numComparison = Math.max(numComparison, A[i]);
            if (numComparison == i + 1) {
                count++;
            }
        }
        System.out.println(count);

    }
}

@@ -11,16 +11,610 @@
 dility;%0A
+/**%0AN light bulbs are connected by a wire. Each bulb has a switch associated with it, however due to faulty wiring, a switch also changes the state of all the bulbs to the right of current bulb. Given an initial state of all bulbs, find the minimum number of switches you have to press to turn on all the bulbs. You can press the same switch multiple times.%0A%0ANote : 0 represents the bulb is off and 1 represents the bulb is on.%0A%0AExample:%0A%0AInput : %5B0 1 0 1%5D%0AReturn : 4%0A%0AExplanation :%0A%0Apress switch 0 : %5B1 0 1 0%5D%0Apress switch 1 : %5B1 1 0 1%5D%0Apress switch 2 : %5B1 1 1 0%5D%0Apress switch 3 : %5B1 1 1 1%5D%0A*/
 %0A//light

Update LightBulbs.java