![](https://static.ambitionbox.com/alpha/community/assets/dots.png)
Number and Digits Problem Statement
You are provided with a positive integer N
. Your task is to identify all numbers such that the sum of the number and its digits equals N
.
Example:
Input:
N = 21
Output:
[15]
Explanation:
The only number where the sum of the number and its digits equals 21 is 15, as 15 + 1 + 5 = 21
.
Constraints:
1 <= T <= 10
1 <= N <= 10^{12}
- Time Limit: 1 sec
Input:
The first line contains a single integer ‘T’ representing the number of test cases.
Each test case consists of a single integer ‘N’, which represents the given integer.
Output:
For each test case, print all space-separated integers whose sum of digits with themselves is equal to ‘N’ in increasing order. Print -1 if no such integer exists.
Print a separate line for each test case.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
![](https://static.ambitionbox.com/alpha/community/assets/no-posts.png)
Be the first one to answer
Add answer anonymously...
Popular interview questions of Software Testing Engineer
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