Free written solution

Check if Binary String Has at Most One Segment of Ones (LeetCode 1784): Solution and Explanation

Given a binary string that starts with '1', decide whether all of its ones form one contiguous block.

Read the intuition, approach, code and complexity →