会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
每天进步一点点
博客园
首页
新随笔
联系
订阅
管理
2022年4月5日
位运算技巧
摘要: 1. n & (n - 1) 运算结果恰为把n的二进制位中的最低位的1变为0之后的结果,可用来计算位1的个数。 public class Solution { public int hammingWeight(int n) { int ret = 0; while (n != 0) { n &= n
阅读全文
posted @ 2022-04-05 22:42 hunter-w
阅读(23)
评论(0)
推荐(0)
编辑
公告