1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 14:12:17 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个整数 <code>n</code> ,对于&nbsp;<code>0 &lt;= i &lt;= n</code> 中的每个 <code>i</code> ,计算其二进制表示中 <strong><code>1</code> 的个数</strong> ,返回一个长度为 <code>n + 1</code> 的数组 <code>ans</code> 作为答案。</p>\n\n<p>&nbsp;</p>\n\n<div class=\"original__bRMd\">\n<div>\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 2\n<strong>输出:</strong>[0,1,1]\n<strong>解释:</strong>\n0 --&gt; 0\n1 --&gt; 1\n2 --&gt; 10\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 5\n<strong>输出:</strong>[0,1,1,2,1,2]\n<strong>解释:</strong>\n0 --&gt; 0\n1 --&gt; 1\n2 --&gt; 10\n3 --&gt; 11\n4 --&gt; 100\n5 --&gt; 101\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 &lt;= n &lt;= 10<sup>5</sup></code></li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>进阶:</strong></p>\n\n<ul>\n\t<li>很容易就能实现时间复杂度为 <code>O(n log n)</code> 的解决方案,你可以在线性时间复杂度 <code>O(n)</code> 内用一趟扫描解决此问题吗?</li>\n\t<li>你能不使用任何内置函数解决此问题吗C++ 中的&nbsp;<code>__builtin_popcount</code> </li>\n</ul>\n</div>\n</div>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 948,
"likes": 977,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Number of 1 Bits\", \"titleSlug\": \"number-of-1-bits\", \"difficulty\": \"Easy\", \"translatedTitle\": \"\\u4f4d1\\u7684\\u4e2a\\u6570\"}]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"198.7K\", \"totalSubmission\": \"252.6K\", \"totalAcceptedRaw\": 198736, \"totalSubmissionRaw\": 252616, \"acRate\": \"78.7%\"}",
"stats": "{\"totalAccepted\": \"207.8K\", \"totalSubmission\": \"264.3K\", \"totalAcceptedRaw\": 207848, \"totalSubmissionRaw\": 264325, \"acRate\": \"78.6%\"}",
"hints": [
"You should make use of what you have produced already.",
"Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous.",