1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/检查二进制字符串字段 [check-if-binary-string-has-at-most-one-segment-of-ones].html

30 lines
904 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个二进制字符串 <code>s</code> ,该字符串 <strong>不含前导零</strong></p>
<p>如果 <code>s</code> 包含 <strong>零个或一个由连续的 <code>'1'</code> 组成的字段</strong> ,返回 <code>true</code> 。否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "1001"
<strong>输出:</strong>false
<strong>解释:</strong>由连续若干个&nbsp;<code>'1'</code> 组成的字段数量为 2返回 false
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "110"
<strong>输出:</strong>true</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>s[i]</code><code>'0'</code><code>'1'</code></li>
<li><code>s[0]</code><code>'1'</code></li>
</ul>