一、位1的个数

题目:191. Number of 1 Bits

C++ Soution 1:

 1 class Solution {
 2 public:
 3     int hammingWeight(uint32_t n) 
 4     {
 5         int res = 0;
 6         for (int i = 0; i < 32; ++i) 
 7         {
 8             res += (n & 1);
 9             n = n >> 1;
10         }
11         return res;
12     }
13 };

二、第k个排列

 题目:60. Permutation Sequence

C++ Soution 1:

相关文章:

  • 2022-01-03
  • 2021-04-07
  • 2021-07-21
  • 2021-12-15
  • 2021-12-06
  • 2021-12-08
  • 2022-12-23
  • 2022-02-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-12-21
  • 2021-06-06
  • 2021-11-25
相关资源
相似解决方案