1 class Solution {
 2 public:
 3     /*
 4      * @param n: An integer
 5      * @return: True or false
 6      */
 7     bool checkPowerOf2(int n) {
 8         // write your code here
 9         return n > 0 && ((n & (n - 1)) == 0);
10     }
11 };

 

相关文章:

  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-08-17
  • 2021-07-28
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案