Digit Sum
InterviewTime limit1sMemory limit512 MB
Given an integer N up to 10^20, find the smallest integer greater than N whose digits sum to the same value as N's digits.
- Level
Medium7 of 10
- Topics
- Greedy, Math, Implementation, String
- Solved
- No attempts yet
Problem
Given an integer , find the smallest number greater than that has the same digit sum as .
The digit sum of an integer is the sum of its digits. For example, 9550 has digit sum , and 999 has digit sum .
Input
An integer, .
Output
Print the smallest number greater than that has the same digit sum as .