pseudocode notation / find a pair such that when you subtract one from the other it should equal to zero in mod n
Initialize all items of the array X by -1
For at most m steps:
- Pick a number from the
set A
and keep it in the variablea
- Remove
a
from theset A
- Calculate
r = a mod n
(remainder ofa / n
) - If
X[r] = -1
(there is noa
such thatr = a mod n
before), then setX[r] = a
, Else, (there wasa
such thatr = a mod n
before) so return thepair (X[r], a)
which both have the same remainder respect withn
.