Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool helper(int n){
- if(n==1) return true;
- if(n%2==1) return false;
- return helper(n/2);
- }
- bool isPowerOfTwo(int n) {
- if(n<=0)return false;
- return helper(n);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement