SA
) and Bob (SB
).d = (SB - SA) / 2
.setB
containing all of Bob's candy sizes for constant time look-up.x
in Alice's array.
a. Calculate the required candy size y
that Alice needs to receive using the equation y = x + d
.
b. Check if y
is in setB
.
c. If y
is found, return the pair [x, y]
as the answer.