Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 370 Bytes

1513.-number-of-substrings-with-only-1s.md

File metadata and controls

19 lines (14 loc) · 370 Bytes

1513. Number of Substrings With Only 1s

class Solution:
    def numSub(self, s: str) -> int:
        if not s: return 0
        ss = s.split("0")
        ans = 0
        for s in ss:
            ans+= self.count(s)
            
        return ans %(10**9+7)
        
        
    def count(self,s):
        n = len(s)
        return int((n * (n+1))/2)