231. Power of Two

PHOTO EMBED

Thu Mar 02 2023 11:35:40 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

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

https://leetcode.com/problems/power-of-two/