2025-08-15 15:03:12 +0300 MSK
Check if Binary String Has at Most One Segment of Ones
Links
Code
class Solution:
def checkOnesSegment(self, s: str) -> bool:
enc = False
for char in s[1:]:
if char == "1" and enc:
return False
elif char == "1":
continue
enc = True
return True