Easy
Check if Binary String Has at Most One Segment of Ones — Python
Full explanation · Time O(n) · Space O(1)
# Time: O(n)
# Space: O(1)
class Solution(object):
def checkOnesSegment(self, s):
"""
:type s: str
:rtype: bool
"""
return "01" not in s