当前位置:网站首页>JZ15 二进制中1的个数
JZ15 二进制中1的个数
2022-07-20 21:38:00 【syc596】
二进制中1的个数_牛客题霸_牛客网 (nowcoder.com)
// import java.util.*;
// public class Solution {
// public int NumberOf1(int n) {
// int count=0;
// while(n!=0){
// if((n&1)==1){
// count++;
// }
// n=n>>>1;//无符号右移
// }
// return count;
// }
// }
import java.util.*;
public class Solution {
public int NumberOf1(int n) {
int count=0;
while(n!=0){
n=n&(n-1);
count++;
}
return count;
}
}
边栏推荐
- TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation
- What if the download of Duoyu security browser is blocked? Turn off the method of download blocking
- If no linetype is selected, the reason why cacuilinetypecombobox crashes
- Excuse me, boss, how does Flink achieve real-time data synchronization between MySQL database and elastic search
- Dama Chapter 9 (document and content management)
- In the e-commerce industry with fierce competition, why can the chain 2+1 mode survive for so long?
- Source code, complement and fixed-point number operation
- 2.3 branch statements
- Facebook will reduce resources related to news products and focus on meta universe and short video content creation
- Opengauss kernel analysis: query rewriting
猜你喜欢
Code implementation of binary tree node number and leaf node number (C language)
How to conduct user retention analysis?
conda虚拟环境默认路径如何修改
Solve the problem of error reporting in NPM installation NRM syntaxerror: unexpected token import
每日一題-LeetCode1260-二維網格遷移-數組-映射
In the future, a new way of tourism, VR traveling without leaving home, embracing poetry and distance
Dama Chapter 4 (data architecture)
Dama summary (summary of data management)
Let's go - Recruitment book for reading activities in 2022 (issue 1)
Which is the best multilingual mall system? Comparison of three famous cross-border e-commerce manufacturers
随机推荐
Esp8266 nodemcu - connect WiFi using WiFi manager Library
Scanning code for vulnerabilities -- those that need to be rectified
In the standard mode, the SQL node of the production environment can perform routine_ sql_ test_ Tianyi conducts sel
In depth analysis: how chain 2+1 mode plays with investment attraction and drainage
Blueprism tool menu bar user rights function description -rpa Chapter 2
这款国产API神器工具也太强了吧...让我放弃了postman
获取当前 标注样式dimstyle
[example] input text in the input box to output the typewriter effect
[JS] mouse follow
2.8 component life cycle
Cluster deployment of Apache Druid 0.22 real-time analysis database on CentOS 7
设置 当前样式dimstyle
[JS] tab switching
Bank data management measures
How cloud primitives support enterprise IT governance | Alibaba cloud user group
【STC15控制WS2812 RGB彩灯级联】
Use priority queue_ Queue implements unordered to base_ Value filtering of map on value value value
Upload a folder (including subfolders and files) in VSS
Several stumbling blocks of it entrepreneurs
Daily question-leetcode1260-2d grid migration array mapping