• Home
  • Archives
  • Tags
  • Categories
  • About
  • Search
  • Zh-CN

HomeGo to BottomBack to TopShare Post

Cover image for Interview Classic 150 Questions P191 Number of 1 Bits

Interview Classic 150 Questions P191 Number of 1 Bits

even629
2025-11-25 (Updated: 2025-11-25)
algorithm
Bit Manipulation, LeetCode Interview 150, algorithm

Timeline

timeline

2025-11-25

init

__builtin_popcount

Title:

P191 bit1count

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

can directly use built-in function__builtin_popcount

1
2
3
4
5
6
7
class Solution {
public:
int hammingWeight(int n)
{
return __builtin_popcount(n);
}
};
  • Home
  • Archives
  • Tags
  • Categories
  • About
  • Search
  • Zh-CN
Menu Share Top
Copyright © 2024-2026 even629
  • Home
  • Archives
  • Tags
  • Categories
  • About
  • Search
  • Zh-CN