42. Power of Three
13 Jul 2020 | Daily Algorithms
class Solution {
public:
bool isPowerOfThree(int n) {
if(n == 0)
return false;
while(n!=1)
{
if(n%3 != 0)
return false;
n = n/3;
cout<< n<< " ";
}
return true;
}
};
class Solution {
public:
bool isPowerOfThree(int n) {
if(n == 0)
return false;
while(n!=1)
{
if(n%3 != 0)
return false;
n = n/3;
cout<< n<< " ";
}
return true;
}
};
Comments