3 ms·
The true insight here is not using XOR, it's sliding the window efficiently. Here is pseudocode not using XOR. members = [0]*len(alphabet) for i in 0.
by toxik 4y ago
The true insight here is not using XOR, it's sliding the window efficiently. Here is pseudocode not using XOR.
members = [0]*len(alphabet)
for i in 0...input length:
members[input[i-window_size]] = 0 if bounds ok
members[input[i]] = 1
if sum(members) == window_size:
return i
If `members` is a bit vector and `sum()` is a popcount, this code is equivalent.