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