2022-03-27 20:45:09 +08:00
< p > Given a binary string < code > s< / code > < strong > without leading zeros< / strong > , return < code > true< / code > < em > if < / em > < code > s< / code > < em > contains < strong > at most one contiguous segment of ones< / strong > < / em > . Otherwise, return < code > false< / code > .< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:45:09 +08:00
< pre >
< strong > Input:< / strong > s = " 1001"
< strong > Output:< / strong > false
< strong > Explanation: < / strong > The ones do not form a contiguous segment.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:45:09 +08:00
< pre >
< strong > Input:< / strong > s = " 110"
< strong > Output:< / strong > true< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = s.length < = 100< / code > < / li >
< li > < code > s[i]< / code > is either < code > ' 0' < / code > or < code > ' 1' < / code > .< / li >
< li > < code > s[0]< / code > is < code > ' 1' < / code > .< / li >
< / ul >