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 whose sum with 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 of digits fo...read more
Help your peers!
Add answer anonymously...
Top Mts1 Interview Questions Asked at Oracle
Q. What is a singleton class?
Q. Check if a Number is Binary Determine if a given string of integers bin represen...read more
Q. What will be the result when adding two binary numbers in a 64-bit and a 32-bit ...read more
Interview Questions Asked to Mts1 at Other Companies
Top Skill-Based Questions for Oracle Mts1
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Operating Systems 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

