Categories: Algorithmic Problem

Algorithm Problem 2: Easy

Algorithm Problem Solution

Hey, try to solve this. This is an easy problem to solve.

Problem Level: Easy

Problem Statement:

A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name “anna” is a palindrome. Numbers can also be palindromes (e.g. 151 or 753357).

Additionally numbers can of course be ordered in size. The first few palindrome

numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, …

The number 10 is not a palindrome (even though you could write it as 010) but a zero as leading digit is not allowed.

Input:

The input consists of a series of lines with each line containing one integer value i (1 ≤ i ≤2*109).

This integer value i indicates the index of the palindrome number that is to be written to the output, where index 1 stands for the first palindrome number (1), index 2 stands for the second palindrome number (2) and so on. The input is terminated by a line containing 0.

Output:

For each line of input (except the last one) exactly one line of output containing a single (decimal) integer value is to be produced. For each input value i the i-th palindrome number is to be written to the output.

Sample Input                                                 Output for Sample Input

1                                                                    1
12                                                                  33
24                                                                  151

Surya

Living in permanent beta mode: Learning, Improving & evolving. SPECIALTIES: Web Application Development, Digital Media, E-Commerce Solutions, SEO, CRM Solutions, Open Source Technologies, System Administration ( Linux ), VOIP Solutions, Cloud Computing, Web Security.

Share
Published by
Surya

Recent Posts

How to get the all the database and table sizes of MySQL or MariaDB?

If you are working with MySQL or MariaDB web server, sooner or later you will…

7 years ago

How to set or change default text editor for crontab in Linux?

To edit the crontab entries you use crontab -e. The command will check for the…

7 years ago

How to install Comodo SSL certificate with NGNIX web server?

Installation method for COMODO SSL Certificate If you have generated the CSR and purchased or…

7 years ago

How to give access to specific users to specific buckets on AWS S3

In AWS S3, you might want to provide the access to selected users to selected…

7 years ago

How to add or change the password (passphrase) of OpenSSH key?

It's possible you have earlier generated a ssh key without password/ passphrase. Later you found…

7 years ago

How to find files on linux OS ( distributions )

If you are working on Linux OS, finding files effectively always a tricky part. Like…

7 years ago