Can you do it in linear time in the length of the input?
In practice, that would actually be slower on this input, because of the cost of initializing the bitset. But that is not dependent on the input, so computational complexity is unaffected.
edit: Removed description. Yes, you're right, you can't even look at the whole input in constant time.