← ALL NOTES
String

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

Binary string s that starts with '1'. Check that all the ones form a single contiguous block — no pattern like "1…0…1". One pass with a flag that latches once the first block of ones ends.

Loading…