Skip to content

Commit 6ec95e0

Browse files
committed
Runtime: 7 ms (Top 90.63%) | Memory: 63.60 MB (Top 8.33%)
1 parent d5e3634 commit 6ec95e0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Runtime: 7 ms (Top 90.63%) | Memory: 63.60 MB (Top 8.33%)
2+
3+
class Solution {
4+
public int numberOfGoodSubarraySplits(int[] nums) {
5+
int count=0;
6+
long ans=1;
7+
int check_1=0;
8+
for(int i=0;i<nums.length;i++){
9+
if(nums[i]==0){
10+
if(check_1==1)
11+
count++;
12+
}
13+
else{
14+
if(check_1==0){
15+
check_1=1;
16+
count++;
17+
}
18+
else{
19+
ans=(ans*count)%1000000007;
20+
// Again start counting no. of 0's making count=1
21+
count=1;
22+
}
23+
}
24+
}
25+
if(count==0) return 0;
26+
return (int)ans;
27+
}
28+
}

0 commit comments

Comments
 (0)