Description
Solutions
Give Minimum Sum
๐RELATED PROBLEMS
Give the minimum sum of (x+y)
such that A
and B
are given and (A+x)
should be multiple of (B+y)
.
Example 1:
Input: A = 8, B = 16
Output: 0
Explanation:Educated guess - SinceA
is already a multiple ofB
, no additional sum is needed. Therefore, the answer is0
.
Example 2:
Input: A = 7, B = 37
Output: 4
Explanation:Educated guess - The minimum sum of(x+y)
to make(A+x)
a multiple of(B+y)
is4
. This can be achieved by settingx = 3
andy = 1
, making(A+x) = 10
and(B+y) = 38
, where10
is a multiple of38
.
Constraints:
๐๐

Related Problems
Testcase
Result
Case 1
input:
output: