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.
Be the first one to answer
Add answer anonymously...
Popular interview questions of SDE-2
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app