4 ms·
Yeah, my first thought was that this was a job for a trie. You can inspect your input character by character, and you can rule out most strings by the first byt
by dhosek 4y ago
Yeah, my first thought was that this was a job for a trie. You can inspect your input character by character, and you can rule out most strings by the first byte since it must be h, f or w. If your set is small and static, you can hard-code the trie and it will be superfast, but a long as you can fail fast when checking each character (so don’t use the default hasher in Rust), you can check for matches quickly and easily.