3 ms·
In Go, using strings.Index (from the standard library) will probably out-perform the naive algorithm used in the article — it's well optimised and, for that str
by jimsmart 9y ago
In Go, using strings.Index (from the standard library) will probably out-perform the naive algorithm used in the article — it's well optimised and, for that string length, will use Rabin-Karp search.
- https://golang.org/src/strings/strings_amd64.go?s=720:752#L17 https://golang.org/src/strings/strings_amd64.go?s=720:752#L1...
- https://en.wikipedia.org/wiki/Rabin–Karp_algorithm https://en.wikipedia.org/wiki/Rabin–Karp_algorithm
One would imagine that similar algorithm implementations also exist for the other languages too.