Algorithms
1 Answer
Algorithms
| Flag | PURGE
Given an input n, find the smallest number x such that x % n = 0 and sum of the digits in x is equal to n.
Note: x is so large even long long int can't keep it.
It is obvious that find the sum of digits using (x/10) gives timeout, so how can its complexity be reduced.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
The smallest number x such that x % n =0 happens when x = n. But the second condition sum of digits in x is equal to n fails here.
- Anonymous September 27, 2014