Number of Substrings With Only 1s LeetCode solution in JavaScript

1
var numSub = function (s) {
2
return (
3
s
4
.split("0")
5
.map((a) => (a.length * (a.length + 1)) / 2)
6
.reduce((a, b) => a + b, 0) % 1000000007
7
);
8
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0