首页 > 代码库 > 【LeetCode】231. Power of Two

【LeetCode】231. Power of Two

题目:

Given an integer, write a function to determine if it is a power of two.

非常简单的一道题目

class Solution {public:    bool isPowerOfTwo(int n) {        if (n <= 0) return false;                if (n == 1) return true;                if (n % 2 != 0) return false;                else return isPowerOfTwo(n/2);                return true;    }};

 

【LeetCode】231. Power of Two