- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1375.java
26 lines (24 loc) · 768 Bytes
/
_1375.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
packagecom.fishercoder.solutions.secondthousand;
publicclass_1375 {
publicstaticclassSolution1 {
publicintnumTimesAllBlue(int[] light) {
intblues = 0;
int[] status = newint[light.length]; // 0 means off, 1 means on
for (inti = 0; i < light.length; i++) {
status[light[i] - 1] = 1;
if (checkAllBlues(status, i)) {
blues++;
}
}
returnblues;
}
privatebooleancheckAllBlues(int[] status, intendIndex) {
for (inti = 0; i <= endIndex; i++) {
if (status[i] != 1) {
returnfalse;
}
}
returntrue;
}
}
}