diff --git a/cpp/2205/220526.cpp b/cpp/2205/220526.cpp new file mode 100644 index 0000000..3e6b024 --- /dev/null +++ b/cpp/2205/220526.cpp @@ -0,0 +1,13 @@ +#include + +/** + * 191. Number of 1 Bits + * Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). + */ + +class Solution { +public: + int hammingWeight(uint32_t n) { + return __builtin_popcount(n); + } +};