Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:56:10+00:00 2026-06-09T11:56:10+00:00

I think the question is simple enough to understand.For more clarity I’m giving example

  • 0

I think the question is simple enough to understand.For more clarity I’m giving example :

In the list of 2 digit palindromes, the 7th palindrome is 77 (1st being 11, 2nd being 22 and so on).

Obviously a brute force solution exists but it’s not efficient.

Can anyone suggest me some better solution to solve the problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:56:11+00:00Added an answer on June 9, 2026 at 11:56 am

    First, we can simplify the problem because we only need to look at the first half of the digits (rounding up if there are an odd number of digits). I will call the first set of digits significant digits and the rest non-significant digits.

    This is because the non-significant digits must match the significant digits (in reverse). It is not possible to have another palindrome number with the same leading significant digits and different non-significant digits. The significant digits determine the entire palindrome number.

    Now, we just need to come up with an algorithm to generate the nth valid significant digits. This would be easier if we allowed for leading zeros, so we’ll come up with the algorithm that allows for leading zeros, then tweak the algorithm.

    The first few palindromes (significant digits) would be:

    • 1: 0000
    • 2: 0001
    • 3: 0002
    • …
    • 100: 0099

    So we can find the significant digits of the nth number by finding the decimal representation of (n-1).

    To tweak the algorithm to work when not allowing leading zeros, we would start with a one as the leading digit:

    • 1: 1000
    • 2: 1001
    • 3: 1002
    • …
    • 100: 1099

    This boils down to finding the decimal representation of (n-1) + 1000 = n + 999 and expanding into a full palindrome:

    Example: Find the 113th palindrome of length 9.

    • Determine number of digits to look at: Round up(9 / 2) = 5 –> only look at first 5 digits.
    • Find number to add to get rid of leading zeros: 10^(5-1) = 10000
    • Use formula: (113 – 1) + 10000 = 10112
    • Expanded into palindrome: 101121101

    On a side note, this algorithm could also be generalized to finding the nth palindrome of any ordered set of symbols (or alphabet).

    Generalized algorithm:

    Given: finding palindrome number n , palindrome has m symbols as digits , there are p symbols (10 symbols in decimal)

    • Let q = ceiling(m / 2)
    • Let offset = p ^ (q – 1)
    • Let number = (n – 1) + offset
    • Let answer be number expanded as a palindrome
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think there is a simple solution to this question, just not simple enough
I think question is simple enough. How to add text with ffmpeg vhook is
I think the question is pretty simple, do I need all the rest of
This is a simple question I think. I am trying to search for the
my question is simple i think. I am creating a really simple app which
I think its a rather simple question but I couldn't really find an answer
A simple question, I think: I want to put a tag into an ASP.NET
I think this is a simple question, but I can not find the answer
I think this is a simple question. How do I disable copy from a
Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.