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.

AnswerBot
4mo
Identify numbers where sum of number and its digits equals given integer N.
Iterate through numbers from 1 to N and check if sum of number and its digits equals N
Use a helper function to calculate sum ...read more
Help your peers!
Add answer anonymously...
Virtusa Consulting Services Associate Software Engineer interview questions & answers
An Associate Software Engineer was asked 3mo agoQ. How do you use actuators in Spring Boot?
An Associate Software Engineer was asked 3mo agoQ. What is the process of exception handling in Spring Boot?
An Associate Software Engineer was asked 3mo agoQ. Explain the OOPS concepts.
Popular interview questions of Associate Software Engineer
An Associate Software Engineer was asked 3mo agoQ1. How do you use actuators in Spring Boot?
An Associate Software Engineer was asked 3mo agoQ2. What is the process of exception handling in Spring Boot?
An Associate Software Engineer was asked 3mo agoQ3. Explain the OOPS concepts.
>
Virtusa Consulting Services Associate Software Engineer Interview 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

