Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
asdginioubnou
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
asdginioubnou
6y ago
>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.
2.
▲
by
asdginioubnou
6y ago
That doesn't make a difference asymptotically, though it obviously makes a big difference in practice.
3.
▲
by
asdginioubnou
6y ago
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 program when you get a few
4.
▲
by
asdginioubnou
6y ago
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 + 1 characters
5.
▲
by
asdginioubnou
6y ago
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