Whats wrong in this code for problem The Next Palindrom(PALIN)?

I am trying to solve this question PALIN

I am getting WA for this code but I tried it with more than 50 test cases. Please help

#include<iostream>
#include<string.h>
using namespace std;

string me;
string b;

int push(long n, int l){
    long r = n,m=0;
    int d,oo=1;
        for(int i=0; i<l; i++)
            oo*=10;
        oo=oo/10;
        for(int i=0; i<l; i++){
            m= m + ((n%10)*oo);
            oo/=10;
            n=n/10;
        }

        if(r==m){
            cout<<r<<endl;
            return 0;
        }

        n=r+1;
        int len=0;
        while(n!=0){
            len = len +1;
            n = n/10;
        }
        push(r+1,len);
}

int main(){
    int t;
    cin>>t;
    while(t--){
        long n;
        cin>>n;
        int c = n+1, len=0;
        while(c!=0){
            len = len +1;
            c = c/10;
        }
        push(n+1, len);
        }
    }

int, long, long long, long long unsigned…neither will work…pls have a look at the constraints…hope this helps…:slight_smile:

1 Like

Why?
It is giving the right output. I checked it for 10000000, 9 99, 999 and so on…

At least suggest me the case where it will fail.

try 100000000000000000000000000…it will give a WA…the problem says…1000000 digits!!!

oh, my bad.

Thank You