Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b0d9d70

Browse files
solved 2348. Number of Zero-Filled Subarrays
Signed-off-by: rajput-hemant <rajput.hemant2001@gmail.com>
1 parent 9451ba5 commit b0d9d70

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
impl Solution {
2+
pub fn zero_filled_subarray(nums: Vec<i32>) -> i64 {
3+
let mut nums = nums;
4+
nums.push(1);
5+
6+
let (mut res, mut count) = (0, 0);
7+
for num in nums {
8+
if num == 0 {
9+
count += 1;
10+
} else {
11+
res += count * (count + 1) / 2;
12+
count = 0;
13+
}
14+
}
15+
16+
res
17+
}
18+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /