My approach for this question :)


#1
#define ll long long
#define For(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
void multiplyby2(string &str){
    ll n = str.length();
    reverse(str.begin(),str.end());
    ll carry = 0;
    For(i,0,n){
        ll x = (str[i] - '0');
        x = x + x + carry;
        carry = x / 10;
        x = x % 10;
        str[i] = (char)(x + '0');
    }
    if(carry != 0){
        str.pb((char)(carry + '0'));
    }
    reverse(str.begin(),str.end());
}
bool strcomparator(bool &flag,string &temp,string &A){
    if(temp.length()<A.length()){
        return 1;
    }
    // now the size is equal
    ll n = A.length();
    ll count = 0;
    For(i,0,n){
        if(temp[i] < A[i]){
            return 1;
        }
        else if(temp[i]==A[i]){
            continue;
        }
        else{
            return 0;
        }
    }
    flag = 1;
    return 0;
}
int Solution::power(string A){
    string temp = "2";
    bool flag = 0;
    while(strcomparator(flag,temp,A)){
        multiplyby2(temp);
    }
    if(flag) return 1;
    else return 0;
}