Practice Minimum Addition to Make Integer Beautiful
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two positive integers n and target. An integer is considered beautiful if the sum of its digits is less than or equal to target. Return the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.
Source: Minimum Addition to Make Integer Beautiful on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 16, target = 6
4
# Example 2
n = 467, target = 6
33
# Example 3
n = 1, target = 1
0
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Addition to Make Integer Beautiful.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.