From 0e8f9b9065dc278f9bbd78eb1049a140a7d2733f Mon Sep 17 00:00:00 2001 From: Eat-Swap Date: Thu, 26 May 2022 20:22:59 +0800 Subject: [PATCH] add: 220526 [cpp] --- cpp/2205/220526.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cpp/2205/220526.cpp 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); + } +};