2 / 2
Oct 2018

The next palindrome problem – https://www.spoj.com/problems/PALIN/3

My code for this problem is:
#include <bits/stdc++.h>
using namespace std;

bool palinIdentifier(int in)
{
int digit = 0, n = 0, rev = 0;
n = in;
do
{
digit = in % 10;
rev = (rev * 10) + digit;
in = in/10;
}while (in != 0);
if (n == rev)
{
return true;
}else return false;
}

int main()
{
ios::sync_with_stdio(0);
cin.tie(0);

int T = 0, num = 123; bool ans;
cin >> T;

int K[T];

for (int i = 0; i < T; ++i)
{
	cin >> K[i];
}

for (int i = 0; i < T; ++i)
{

	for (num = K[i]+1; !palinIdentifier(num); ++num){};
    cout << num << endl;

}

return 0;

}

When I test it on my pc with the given input examples it works properly.
But when I submit my solution it says Wrong Answer
WHY?!
Please help!

  • created

    Oct '18
  • last reply

    Oct '18
  • 1

    reply

  • 687

    views

  • 2

    users

  • 1

    link

Try this test case:

1
12345678901234567890123456789012345678901234567890