mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<p>给定一个正整数 <code>n</code> ,返回范围在 <code>[0, n]</code> 都非负整数中,其二进制表示不包含 <strong>连续的 1 </strong>的个数。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> n = 5
|
||||
<strong>输出:</strong> 5
|
||||
<strong>解释:</strong>
|
||||
下面是带有相应二进制表示的非负整数<= 5:
|
||||
0 : 0
|
||||
1 : 1
|
||||
2 : 10
|
||||
3 : 11
|
||||
4 : 100
|
||||
5 : 101
|
||||
其中,只有整数3违反规则(有两个连续的1),其他5个满足规则。</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> n = 1
|
||||
<strong>输出:</strong> 2
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> n = 2
|
||||
<strong>输出:</strong> 3
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= n <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user