I have array like this:
array('1224*', '543*', '321*' ...) which contains about 17,00 "masks" or prefixes.
I have a second array:
array('123456789', '123456788', '987654321' ....) which contain about 250,000 numbers.
Now, how can I efficiently match every number from the second array using the array of masks/prefixes?
[EDIT]
The first array contains only prefixes and every entry has only one * at the end.
Well, here’s a solution:
Prelimary steps:
*‘s.Searching:
number(binary search).firstandlast(binary search).This should be
O(k*n*log(n))wherenis the average number length (in digits) andkthe number of numbers.Basically this is a 1 dimensional Radix tree, for optimal performance you should implement it, but it can be quite hard.