Class Solution
java.lang.Object
g1801_1900.s1869_longer_contiguous_segments_of_ones_than_zeros.Solution
1869 - Longer Contiguous Segments of Ones than Zeros.<p>Easy</p>
<p>Given a binary string <code>s</code>, return <code>true</code> <em>if the <strong>longest</strong> contiguous segment of</em> <code>1</code>‘<em>s is <strong>strictly longer</strong> than the <strong>longest</strong> contiguous segment of</em> <code>0</code>’<em>s in</em> <code>s</code>, or return <code>false</code> <em>otherwise</em>.</p>
<ul>
<li>For example, in <code>s = "110100010"</code> the longest continuous segment of <code>1</code>s has length <code>2</code>, and the longest continuous segment of <code>0</code>s has length <code>3</code>.</li>
</ul>
<p>Note that if there are no <code>0</code>’s, then the longest continuous segment of <code>0</code>’s is considered to have a length <code>0</code>. The same applies if there is no <code>1</code>’s.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “1101”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong></p>
<p>The longest contiguous segment of 1s has length 2: “1101”</p>
<p>The longest contiguous segment of 0s has length 1: “1101”</p>
<p>The segment of 1s is longer, so return true.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “111000”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong></p>
<p>The longest contiguous segment of 1s has length 3: “111000”</p>
<p>The longest contiguous segment of 0s has length 3: “111000”</p>
<p>The segment of 1s is not longer, so return false.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “110100010”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong></p>
<p>The longest contiguous segment of 1s has length 2: “110100010”</p>
<p>The longest contiguous segment of 0s has length 3: “110100010”</p>
<p>The segment of 1s is not longer, so return false.</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>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
checkZeroOnes
-