Skip to content

Commit c6a0f44

Browse files
fix format for js
1 parent f89e182 commit c6a0f44

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

Diff for: javascript/_485.js

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
var findMaxConsecutiveOnes = function(nums) {
2-
3-
let slow = 0
4-
let fast = 0
5-
let max = 0
6-
while(fast < nums.length){
7-
if(nums[fast] === 0){
8-
if(fast - slow > max ) {
9-
max = fast - slow
10-
}
11-
fast++;
12-
slow = fast
13-
} else {
14-
fast++
15-
}
16-
}
17-
return fast - slow > max ? fast - slow : max
18-
19-
}
1+
var findMaxConsecutiveOnes = function (nums) {
2+
let slow = 0
3+
let fast = 0
4+
let max = 0
5+
while (fast < nums.length) {
6+
if (nums[fast] === 0) {
7+
if (fast - slow > max) {
8+
max = fast - slow
9+
}
10+
fast++
11+
slow = fast
12+
} else {
13+
fast++
14+
}
15+
}
16+
return fast - slow > max ? fast - slow : max
17+
}
2018

19+
console.log(findMaxConsecutiveOnes([2, 7, 11, 15]))

0 commit comments

Comments
 (0)