There's a single pass solution that's left as an exercise for the reader.
There's a single pass solution that's left as an exercise for the reader.
Isn't that the point? You say it like it's a problem, but it screens for someone who's reasonably prepared, which is probably what Google wants to do because they really start looking for the super-world-tier people they employ, because I guess that takes more time and resources.
> There's a single pass solution that's left as an exercise for the reader.
Doesn't the blog post already include a single-pass solution that works on a small alphabet?
Definitely. That's why it makes a good question for the initial screening. If you can't come up with the O(N) solution, there's very little chance you'll pass the on-site interviews.
> Doesn't the blog post already include a single-pass solution that works on a small alphabet?
It's actually two passes: one to create the set, and one more again to find the character. There's a solution you can do in only one pass through the string and one through the alphabet. Complexity is the same, but it's far fewer operations for the specific example given.
Those are combined into a single pass in the example in the article, aren't they?
I don't see what changes with a small alphabet. Or are you searching for multiple ocurrences of sequences instead of single characters?