2025-08-15 15:04:18 +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:
if char == "1":
if enc:
return False
elif not enc:
enc = True
return True