Problem ยท Math

Give Minimum Sum

Learn this problem
โ— MediumDeutsche BankOA

Problem statement

Give the minimum sum of (x+y) such that A and B are given and (A+x) should be multiple of (B+y).

Function

giveMinimumSum(A: int, B: int) โ†’ int

Examples

Example 1

A = 8B = 16return = 0
Educated guess - Since A is already a multiple of B, no additional sum is needed. Therefore, the answer is 0.

Example 2

A = 7B = 37return = 4
Educated guess - The minimum sum of (x+y) to make (A+x) a multiple of (B+y) is 4. This can be achieved by setting x = 3 and y = 1, making (A+x) = 10 and (B+y) = 38, where 10 is a multiple of 38.

Constraints

๐ŸŠ๐ŸŠ

More Deutsche Bank problems

drafts saved locally
public int giveMinimumSum(int A, int B) {
  // write your code here
}
A8
B16
expected0
checking account