Skip to content

Commit

Permalink
Merge pull request #2116 from paditya99/master
Browse files Browse the repository at this point in the history
Added CPP solution for LeetCode question of Power of Four
  • Loading branch information
fineanmol authored Oct 3, 2022
2 parents f92f570 + d8f4060 commit b11169a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Program's_Contributed_By_Contributors/C++/PowerOfFour.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Solution {
public:
double value4(double d)
{
return (log2(d))/2;
}
bool is_integer(float k)
{
return std::floor(k) == k;
}
bool isPowerOfFour(int n) {
if(n<=0){
return false;
}
if(n==1){
return true;
}
if(n%4!=0){
return false;
}
else{
if(is_integer(value4(n))){
return true;
}
else{
return false;
}
}
}
};

0 comments on commit b11169a

Please sign in to comment.