1
class Solution {
2
public:
3
bool reorderedPowerOf2(int n) {
4
string str = to_string(n);
5
sort(str.begin(), str.end());
6
long long int num;
7
int counter = 0;
8

9
while (true) {
10
num = pow(2, counter++);
11

12
string temp = to_string(num);
13

14
if (temp.length() > str.length()) {
15
// cout<<"temp="<<temp<<endl;
16
break;
17
}
18

19
sort(temp.begin(), temp.end());
20

21
if (str == temp) return true;
22
}
23
return false;
24
}
25
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0