Easy to understand solution (using log)


#1
bool is_integer(float k)
{
  return std::floor(k) == k;
}

int Solution::isPower(int A) {
if(A==1)return 1;
for(int i=2; i<A; i++)
{
    if(is_integer(log(A)/log(i)))return 1;
}
return 0;
}

#2

I don’t think we need to loop till i<A

for(int i=2; i<=sqrt(A); i++)

would work fine