We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96fc45e commit f3e49eaCopy full SHA for f3e49ea
scripts/algorithms/N/Number of Ways to Split a String/Number of Ways to Split a String.js
@@ -1,11 +1,12 @@
1
+// Runtime: 91 ms (Top 100.00%) | Memory: 47.1 MB (Top 69.23%)
2
var numWays = function(s) {
3
let one = 0;
4
let list = [];
5
for(let i = 0; i < s.length; i++){
6
if(s[i]==="1") one++, list.push(i);
7
}
8
if(one%3!==0) return 0;
- if(one===0) return ((s.length-1)*(s.length-2)/2) % 1000000007;
9
+ if(one===0) return ((s.length-1)*(s.length-2)/2) % 1000000007;
10
one/=3;
11
return ((list[one]-list[one-1])*(list[2*one]-list[2*one-1])) % 1000000007;
-};
12
+};
0 commit comments