• 首页
  • 归档
  • 标签
  • 关于
  • 搜索
  • EN

查找首页直达底部返回顶部分享文章切换主题色

查找
Cover image for 面试经典150题 P191 位1的个数

面试经典150题 P191 位1的个数

Created:2025-11-25 13:31:13Updated:2025-11-25 13:31:13
algorithm
algorithm, leetcode面试经典150题, 位操作
字数 59
阅读
访客

时间轴

时间轴

2025-11-25

init

__builtin_popcount

题目:

P191 位1的个数

https://leetcode.cn/problems/number-of-1-bits/description/?envType=study-plan-v2&envId=top-interview-150

可以直接使用内置函数__builtin_popcount

1
2
3
4
5
6
7
class Solution {
public:
int hammingWeight(int n)
{
return __builtin_popcount(n);
}
};
  • 首页
  • 归档
  • 标签
  • 关于
  • 搜索
  • EN
菜单 查找 分享 返回顶部
Copyright © 2024-2026 even629
  • 首页
  • 归档
  • 标签
  • 关于
  • 搜索
  • EN