Connection Status:
Competition Arena > IntegerPalindrome
SRM 302 · 2006-05-11 · by Andrew_Lazarev · Math
Class Name: IntegerPalindrome
Return Type: long
Method Name: findByIndex
Arg Types: (int)
Problem Statement

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.

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

Submissions are judged against all 93 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class IntegerPalindrome with a public method long long findByIndex(int K) · 93 test cases · 2 s / 256 MB per case

Submitting as anonymous