We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d5e3634 commit 6ec95e0Copy full SHA for 6ec95e0
scripts/algorithms/W/Ways to Split Array Into Good Subarrays/Ways to Split Array Into Good Subarrays.java
@@ -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
17
18
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