Find the longest prefix of bit arrays

Viewed 1416

I'm trying to find a fast algorithm that search the longest prefix of multiple bit arrays. In my application, those bit arrays can be infinitely long and of variable length. For example, if I have those bit arrays:

0b1011001
0b1001101
0b1001010
0b1010100

The longest prefix would be 10. I'm currently ORing and NANDing the bit arrays to find their common 0s and 1s and XORing the results together.

OR
0b1011111

NAND
0b0111111

XOR
0b1100000

Is there a any faster solution?

4 Answers
Related