We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 406be85 commit 2c10e7fCopy full SHA for 2c10e7f
javascript/2348-number-of-zero-filled-subarrays.js
@@ -0,0 +1,21 @@
1
+/*
2
+ * Time O(N) | Space O(1)
3
+ * https://leetcode.com/problems/number-of-zero-filled-subarrays
4
+ */
5
+/**
6
+ * @param {number[]} nums
7
+ * @return {number}
8
9
+var zeroFilledSubarray = function(nums) {
10
+ let total, count;
11
+ total = count = 0;
12
+ for(let element of nums){
13
+ if(element == 0){
14
+ count ++;
15
+ total += count;
16
+ }else{
17
+ count = 0;
18
+ }
19
+ };
20
+ return total;
21
+};
0 commit comments