
Asked in TCS
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
5mo
211
Comment deleted
Test me User
1y
student at
Indian Institute of Technology (IIT), Roorkee
Yes
Add answer anonymously...
Top Software Developer Interview Questions Asked at TCS
Q. What is Python?
Q. What is SQL?
Q. What is the process for synthesizing data to train a machine learning model with...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for TCS Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
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

