TopCoder problem "IntegerPalindrome" used in SRM 302 (Division I Level Two)



Problem Statement

    

A positive integer is called a palindrome if it reads the same forward and backward. Integers containing leading zeros are not valid. For example, 12321 is a palindrome, but 123210 is not. You are given an int K. Return the K-th palindrome, where the 0th palindrome is 1, the 1st palindrome is 2, etc.

 

Definition

    
Class:IntegerPalindrome
Method:findByIndex
Parameters:int
Returns:long
Method signature:long findByIndex(int K)
(be sure your method is public)
    
 

Constraints

-K will be between 0 and 1000000000 (109), inclusive
 

Examples

0)
    
8
Returns: 9
1)
    
9
Returns: 11
2)
    
19
Returns: 111
3)
    
235
Returns: 13731
4)
    
23746
Returns: 137484731

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=6184

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=9823&pm=6184

Writer:

Andrew_Lazarev

Testers:

PabloGilberto , brett1479 , legakis , Olexiy

Problem categories:

Math