int Solution::reverse(int A) {
bool sign =0;
if(A>=INT_MAX||A<=INT_MIN)
{
return 0;
}
if(A<0)
{
sign=1;
A=-A;
}
int digit = (int)log10(A);
int num = ((A%10)*pow(10,digit)+reverse(A/10));
if(num>INT_MAX)return 0;
if(sign)
{
return -num;
}
return num;
}
The code is showing memory limit exceeded when input is -1234567891, is it because of the recursive call?