mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-24 22:38:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>编写一个函数,输入是一个无符号整数(以二进制串的形式),返回其二进制表达式中数字位数为 '1' 的个数(也被称为 <a href=\"http://en.wikipedia.org/wiki/Hamming_weight\" target=\"_blank\">汉明重量</a>).)。</p>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>请注意,在某些语言(如 Java)中,没有无符号整数类型。在这种情况下,输入和输出都将被指定为有符号整数类型,并且不应影响您的实现,因为无论整数是有符号的还是无符号的,其内部的二进制表示形式都是相同的。</li>\n\t<li>在 Java 中,编译器使用 <a href=\"https://baike.baidu.com/item/二进制补码/5295284\">二进制补码</a> 记法来表示有符号整数。因此,在上面的 <strong>示例 3 </strong>中,输入表示有符号整数 <code>-3</code>。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 11 (控制台输入 00000000000000000000000000001011)\n<strong>输出:</strong>3\n<strong>解释:</strong>输入的二进制串 <code><strong>00000000000000000000000000001011</strong> 中,共有三位为 '1'。</code>\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 128 (控制台输入 00000000000000000000000010000000)\n<strong>输出:</strong>1\n<strong>解释:</strong>输入的二进制串 <strong>00000000000000000000000010000000</strong> 中,共有一位为 '1'。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 4294967293 (控制台输入 11111111111111111111111111111101,部分语言中 n = -3)\n<strong>输出:</strong>31\n<strong>解释:</strong>输入的二进制串 <strong>11111111111111111111111111111101</strong> 中,共有 31 位为 '1'。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>输入必须是长度为 <code>32</code> 的 <strong>二进制串</strong> 。</li>\n</ul>\n\n<p> </p>\n\n<p>注意:本题与主站 191 题相同:<a href=\"https://leetcode-cn.com/problems/number-of-1-bits/\">https://leetcode-cn.com/problems/number-of-1-bits/</a></p>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 236,
|
||||
"likes": 237,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -89,7 +89,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"243.2K\", \"totalSubmission\": \"324.4K\", \"totalAcceptedRaw\": 243209, \"totalSubmissionRaw\": 324376, \"acRate\": \"75.0%\"}",
|
||||
"stats": "{\"totalAccepted\": \"244K\", \"totalSubmission\": \"325.4K\", \"totalAcceptedRaw\": 244004, \"totalSubmissionRaw\": 325356, \"acRate\": \"75.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
||||
Reference in New Issue
Block a user