Love丶FFC's Blog
写一个函数,其以无符号整数为输入,而输出对应二进制数所具有的“1”的位数(也被称为汉明权重)
样例 1
输入:n = 11
输出:3
解析:11(10) = 1011(2), 返回 3
样例 2
输入:n = 7
输出:3
解析:7(10) = 111(2), 返回 3
1.直接使用十进制数转二进制数的算法即可。
2.如11(10)转换为二进制数的过程为:
11/2=5,此时余数=1。
5/2=2,此时余数=1。
2/2=1,此时余数为0。
1/2=0,此时余数为1。
因此11(10)=1011(2),本题直接累加余数为1的次数即可。
public class Solution { public int hammingWeight(int n) { int total=0; while(n!=0) { total=(n%2==1)?total+1:total; n/=2; } return total; } }
public class Solution { public int hammingWeight(int n) { int total=0; while(n!=0) { total=(n%2==1)?total+1:total; n/=2; } return total; } }
Jorcift
Finally, in vitro studies have shown that epigenetic reprogramming might play a central role in ERО± BC cells that adapt to endocrine therapy 16, 17 propecia viagra combined Recent studies report the prevalence of taste disturbances in chemotherapy patients is high, ranging from 65 to 80 1 5
intuido
levitra que hace Also see our top choices for L Theanine
intuido
Cells were transfected with Atg7 siRNA Santa Cruz, sc 41448 or Tlr4 siRNA Santa Cruz, sc 40261 using lipofectamine 2000 Invitrogen buy cialis 5mg
iEUPyqgxw
Prigge ST, Kolhekar AS, Eipper BA et al 1999 Substrate mediated electron transfer in peptidylglycine alpha hydroxylating monooxygenase generic propecia