Problem Brief
Equal Difference Pairs
INTERNOA
See the Image Source section at the bottom of this page for the original problem descritpion and example explanation :)
Imagine two friends, Alice and Bob, who both have lists of numbers. They want to play a game to see how many special pairs they can find. Each pair consists of two numbers, one from Alice's list and one from Bob's list. But there's a twist: they are only interested in pairs where a certain condition is met.
1Example 1
Input
a = [2, -2, 5, 3], b = [1, 5, -1, 1]
Output
6
Explanation
For (i, j) = (0, 0) equality holds: a[0] - b[0] = 2 - 1 = 1 and a[0] - b[0] = 2 - 1 = 1
For (i, j) = (0, 1) equality holds: a[0] - b[1] = 2 - 5 = -3 and a[1] - b[0] = -2 - 1 = -3
For (i, j) = (0, 2) equality doesn't hold: a[0] - b[2] = 2 - (-1) = 3 and a[2] - b[0] = 5 - 1 = 4
For (i, j) = (0, 3) equality doesn't hold: a[0] - b[3] = 2 - 1 = 1 and a[3] - b[0] = 3 - 1 = 2
For (i, j) = (1, 1) equality holds: a[1] - b[1] = (-2) - 5 = -7 and a[1] - b[1] = -2 - 5 = -7
For (i, j) = (1, 2) equality does not holds: a[1] - b[2] = (-2) - (-1) = -1 and a[2] - b[1] = 5 - 5 = 0
For (i, j) = (1, 3) equality does not holds: a[1] - b[3] = (-2) - 1 = -3 and a[3] - b[1] = 3 - 5 = -2
For (i, j) = (2, 2) equality holds: a[2] - b[2] = 5 - (-1) = 6 and a[2] - b[2] = 5 - (-1) = 6
For (i, j) = (2, 3) equality holds: a[2] - b[3] = 5 - 1 = 4 and a[3] - b[2] = 3 - (-1) = 4
For (i, j) = (3, 3) equality holds: a[3] - b[3] = 3 - 1 = 2 and a[3] - b[3] = 3 - 1 = 2
2Example 2
Input
a = [25, 0], b = [0, 25]
Output
3
Explanation
n/a
Constraints
Limits and guarantees your solution can rely on.
๐๐