Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 260 Bytes

1784.-check-if-binary-string-has-at-most-one-segment-of-ones.md

File metadata and controls

11 lines (8 loc) · 260 Bytes

1784. Check if Binary String Has at Most One Segment of Ones

class Solution:
    def checkOnesSegment(self, s: str) -> bool:
        
        s = s.split("0")
        ans = sum([1 for x in list(map(len,s)) if x > 0 ])
        return ans <= 1