There are two sets of integers with different numbers of items in them.
X= { x_0, x_1, ... x_n }, x_0 < x_1 < ... < x_n
Y= { y_0, y_1, ... y_m }, y_0 < y_1 < ... < y_m
And there is a function of a single integer defined as
F(delta) = CountOfItems( Intersection( X, { y_0+delta, y_1+delta, ... y_m+delta) ) )
That is - i add delta
integer to every element of the Y
and then count how many same integers are in the X
and the modified Y
.
And then the problem - find delta
that maximizes F(delta)
.
max( F(delta) ), where delta is integer
Is there some "mathematical" name for such task and optimal algorithm for this? Obviously i can use brute-force here and enumerate all possible combination - but it does not work for big n and m.