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

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

Leetcode Solutions

Check for Contiguous Ones Segment

  1. Start iterating through the string from the beginning.
  2. Look for the substring '01' in the string.
  3. If '01' is found, return false.
  4. If the end of the string is reached without finding '01', return true.
UML Thumbnail

Iterative Check for Non-contiguous Ones

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...