Palindromic Numbers Finder
Given an integer 'N', your task is to identify all palindromic numbers from 1 to 'N'. These are numbers that read the same way forwards and backwards.
Input:
The first line provides a single integer 'T', indicating the number of test cases.
Each test case contains a single integer 'N' located on a new line.
Output:
For each test case, print all palindromic numbers from 1 to 'N' in ascending order, separated by spaces.
Print the results for each test case on a separate line.
Example:
Input:
1
12
Output:
1 2 3 4 5 6 7 8 9 11
Explanation:
Every single-digit number qualifies as a palindrome, and additionally, the number 11 also qualifies as a palindrome.
Constraints:
1 <= T <= 10
1 <= N <= 10^9
- Time Limit: 1 second
Note:
Your solution should not include printing logic, focus on implementing the function logic only.

AnswerBot
4mo
Implement a function to find all palindromic numbers from 1 to N.
Iterate from 1 to N and check if each number is a palindrome
Use string manipulation to check for palindromes
Consider edge cases like si...read more
RAJ KUSHWAHA R
2mo
def is_palindromic(num): return str(num) == str(num)[::-1] def find_palindromes(N): # Iterate through all numbers from 1 to N and check if they are palindromic palindromic_numbers = [] for num in rang...read more
Rajendra Chauhan
4mo
211
Comment deleted
Test me User
1y
student at
Indian Institute of Technology (IIT), Roorkee
Yes
Add answer anonymously...
TCS Software Developer interview questions & answers
A Software Developer was asked 3w agoQ. What is the process for synthesizing data to train a machine learning model with...read more
A Software Developer was asked 3w agoQ. What is the process flow for converting an infix expression to a postfix express...read more
A Software Developer was asked 1mo agoQ. Write code to reverse a string.
Popular interview questions of Software Developer
A Software Developer was asked 1w agoQ1. What is Python?
A Software Developer was asked 3w agoQ2. What is the process for synthesizing data to train a machine learning model with...read more
A Software Developer was asked 1mo agoQ3. What is a string?
Top HR questions asked in TCS Software Developer
A Software Developer was asked 5d agoQ1. Can you provide an explanation of your project?
A Software Developer was asked 2mo agoQ2. Why should we choose you?
A Software Developer was asked 2mo agoQ3. What are your hobbies?
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

