Skip to content

Commit 376777d

Browse files
committed
342
1 parent 8c9696a commit 376777d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

231.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
bool isPowerOfTwo(int n) {
4+
5+
if(n<=0)
6+
{
7+
return 0;
8+
}
9+
int y=n-1;
10+
int z= y & n;
11+
if(z==0)
12+
{
13+
return 1;
14+
}
15+
return 0;
16+
17+
18+
}
19+
};

342.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
bool isPowerOfFour(int num) {
4+
5+
6+
float yy=(log10 (num)/log10 (4));
7+
8+
if(yy == (int)yy)
9+
{
10+
return 1;
11+
}
12+
else
13+
{
14+
return 0;
15+
}
16+
}
17+
};

0 commit comments

Comments
 (0)