Class Solution
java.lang.Object
g1701_1800.s1784_check_if_binary_string_has_at_most_one_segment_of_ones.Solution
1784 - Check if Binary String Has at Most One Segment of Ones.<p>Easy</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “1001”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> The ones do not form a contiguous segment.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “110”</p>
<p><strong>Output:</strong> true</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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
checkOnesSegment
-