Skip to content

Commit b46d942

Browse files
committed
Create 1375.灯泡开关 III.js
1 parent 6f788cc commit b46d942

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

1375.灯泡开关 III.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} light
3+
* @return {number}
4+
*/
5+
var numTimesAllBlue = function(light) {
6+
let result = 0;
7+
let max = 0;
8+
for (let i = 0; i < light.length; i++) {
9+
if (i === max) {
10+
result++;
11+
}
12+
max = Math.max(max, light[i]);
13+
}
14+
return result;
15+
};

0 commit comments

Comments
 (0)