Sum of N-Digit Palindromes

Determine the sum of all N-digit palindromes for a given integer 'N'. A palindrome is defined as a number that remains the same when its digits are reversed.

Example:

Input:
T = 1
N = 1
Output:
45
Explanation:

For N = 1, the numbers are [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] and all are palindromes. Their sum is 45.

Constraints:

  • 1 ≤ T ≤ 50
  • 1 ≤ N ≤ 12
  • Time Limit: 1 sec
AnswerBot
4mo

Sum of all N-digit palindromes for a given integer N.

  • Generate all N-digit palindromes by iterating through digits 1 to 9 and appending the reverse of the number

  • Calculate the sum of all generated palin...read more

Help your peers!
Select
Add answer anonymously...
Oracle Cerner Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits