base of n positive integers. Someone picked a positive integer k and built two arrays: one with every number decreased by k, the other with every number increased by k. All 2n numbers were then shuffled together into mixed, so it is unknown which number came from which array.
Recover base. If several values of k fit, use the smallest one; for a fixed k, base is determined uniquely. The numbers may be returned in any order.
At least one suitable k is guaranteed to exist.mixed=[9, 3, 13, 7] → [5, 11]
With k = 2, [5, 11] gives [3, 9] and [7, 13]. k = 3 also works ([6, 10]), but the smallest k is required, and k = 1 does not work.
mixed=[4, 4, 10, 10] → [7, 7]
The only option is k = 3 with the original [7, 7]: pairing 4 with 4 would need k = 0, and k must be positive.
mixed=[2, 100] → [51]
base and k existmixed=[9, 3, 13, 7]
[5, 11]
Run checks the first 3 tests in your browser. Submit checks all 78 tests on the server, hidden ones included.