>Let's say there are M different characters in the alphabet and N different characters in the string. I mean "N characters in the string", i.e. the string is length N. There won't be N different characters.
That doesn't make a difference asymptotically, though it obviously makes a big difference in practice.
The second solution is safer than the first. While it will sometimes be slower, it will never be catastrophically bad. It may have a small, predictable overhead, but it will never unexpectedly bring down the whole…
Both solutions are O(1). The alphabet is finite. Let's say there are M different characters in the alphabet and N different characters in the string. If there is a duplicate, it is guaranteed to occur within the first M…
It's definitely wrong. A lot of people use "order of magnitude" to just mean "a lot". I always use the precise meaning. It might be better for me to say "factor of ten" rather than "order of magnitude" if other people…
>Let's say there are M different characters in the alphabet and N different characters in the string. I mean "N characters in the string", i.e. the string is length N. There won't be N different characters.
That doesn't make a difference asymptotically, though it obviously makes a big difference in practice.
The second solution is safer than the first. While it will sometimes be slower, it will never be catastrophically bad. It may have a small, predictable overhead, but it will never unexpectedly bring down the whole…
Both solutions are O(1). The alphabet is finite. Let's say there are M different characters in the alphabet and N different characters in the string. If there is a duplicate, it is guaranteed to occur within the first M…
It's definitely wrong. A lot of people use "order of magnitude" to just mean "a lot". I always use the precise meaning. It might be better for me to say "factor of ten" rather than "order of magnitude" if other people…