当前位置:网站首页>剑指offer基础版 --- 第21天
剑指offer基础版 --- 第21天
2022-07-31 05:09:00 【米兰的小红黑】

public class Solution {
// you need to treat n as an unsigned value
public int hammingWeight(int n) {
int x = 0;
while(n != 0){
if((n & 1) == 1){
x++;
n = n >>> 1;
}else{
n = n >>> 1;
}
}
return x;
}
}

class Solution {
public int add(int a, int b) {
int res = a;
while(b != 0){
res = a ^ b;
b = (a & b) << 1;
a = res;
}
return res;
}
}
边栏推荐
猜你喜欢

一文了解大厂的DDD领域驱动设计
【一起学Rust】Rust学习前准备——注释和格式化输出

Mysql application cannot find my.ini file after installation

MySQL-如何分库分表?一看就懂

ES source code API call link source code analysis

12个MySQL慢查询的原因分析

Lock wait timeout exceeded解决方案

剑指offer专项突击版 ---- 第2天

Unity mobile game performance optimization series: performance tuning for the CPU side

面试Redis 高可靠性|主从模式、哨兵模式、Cluster集群模式
随机推荐
EasyExcel的简单读取操作
信息系统项目管理师核心考点(五十五)配置管理员(CMO)的工作
Apache DButils使用注意事项--with modifiers “public“
SQL row-column conversion
matlab abel变换图片处理
2022-07-30:以下go语言代码输出什么?A:[]byte{} []byte;B:[]byte{} []uint8;C:[]uint8{} []byte;D:[]uin8{} []uint8。
The monitoring of Doris study notes
账号或密码多次输入错误,进行账号封禁
[mysql improves query efficiency] Mysql database query is slow to solve the problem
Mysql application cannot find my.ini file after installation
mysql stored procedure
MySQL优化之慢日志查询
<urlopen error [Errno 11001] getaddrinfo failed>的解决、isinstance()函数初略介绍
快速掌握并发编程 --- 基础篇
剑指offer专项突击版 ---- 第 6 天
On-line monitoring system for urban waterlogging and water accumulation in bridges and tunnels
Summary of MySQL common interview questions (recommended collection!!!)
docker安装postgresSQL和设置自定义数据目录
.NET-6.WinForm2.NanUI learning and summary
A complete introduction to JSqlParse of Sql parsing and conversion