Skip to content

Commit 30123ff

Browse files
authored
Create 2348-number-of-zero-filled-subarrays.kt
1 parent 407b156 commit 30123ff

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
fun zeroFilledSubarray(nums: IntArray): Long {
3+
var res = 0L
4+
5+
var i = 0
6+
while(i < nums.size) {
7+
if(nums[i] == 0) {
8+
var j = i
9+
var count = 0L
10+
while(j < nums.size && nums[j] == 0) {
11+
j++
12+
count++
13+
}
14+
println(count)
15+
res += count * (1 + count) / 2
16+
i = j
17+
}else{
18+
i++
19+
}
20+
}
21+
22+
return res
23+
}
24+
}

0 commit comments

Comments
 (0)