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)/交替位二进制数 [binary-number-with-alternating-bits].html
2022-03-29 12:43:11 +08:00

34 lines
818 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>给定一个正整数,检查它的二进制表示是否总是 0、1 交替出现:换句话说,就是二进制表示中相邻两位的数字永不相同。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 5
<strong>输出:</strong>true
<strong>解释:</strong>5 的二进制表示是101
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 7
<strong>输出:</strong>false
<strong>解释:</strong>7 的二进制表示是111.</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 11
<strong>输出:</strong>false
<strong>解释:</strong>11 的二进制表示是1011.</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
</ul>