We’re preparing your current view and syncing the latest data.
Given a binary string s, return true if s contains at most one contiguous segment of ones. Otherwise, return false.
A string s consisting of characters '0' and '1'.
Return a boolean value: true or false.
1 <= s.length <= 100
Example 1
Input
110
Output
true
Explanation
There is only one contiguous segment of ones.
Example 2
Input
1001
Output
false
Explanation
There are two segments of ones separated by zeros.