TopcoderArchiveVisit Topcoder
SRM11 May 2006
SRM 302

IntegerPalindrome

Problem statement, definition, constraints, and public examples.

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

  1. 8
    Returns: 9
  2. 9
    Returns: 11
  3. 19
    Returns: 111
  4. 235
    Returns: 13731
  5. 23746
    Returns: 137484731
Back to all problems