I think the claim at the end is supposed to say `O(D)` running time rather than `O(N)` (or I can't see where `N` is defined).
Does this technique catch letters duplicated more than once?
In a Python 3 shell:
>> 2 ^ 4
6
>> 2 ^ 4 ^ 2
4
>> 2 ^ 4 ^ 2 ^ 2
6
Yes I guess it does, because inputs are used up in order to turn bits on and off. Nice!