Yes, this algorithm is mainly used to quickly find a substring in a string. O(n+m), where n=len(string), m=len(substring). I can run some tests to check, and post them here. But I would also like to add the z algorithm itself, this will be useful mainly for competitive programmers, and it will become even more popular in competition.
пятница, 17 сентября 2021 г. в 19:54:51 UTC+1, Ian Lance Taylor: > On Fri, Sep 17, 2021 at 8:38 AM vl4deee11 <vladboyc...@gmail.com> wrote: > > > > Hello everyone, I need help, I often write algorithms on strings, and > often I need such a thing as a Z algo, is it possible to add it to a > 'std/strings' package ? > > It can also be used in competitive programming, it is quite a useful > thing. > > > > More about Z algo - > https://www.geeksforgeeks.org/z-algorithm-linear-time-pattern-searching-algorithm/ > > From a quick glance this looks like an efficient way of writing > strings.Contains or strings.Index. If somebody wants to write a > faster version of strings.Index, and can prove it using benchmarks, we > would be happy to include that in the standard library. strings.Index > is already pretty heavily optimized, but if we can make it faster we > will. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/40412bfb-ca84-4cf5-b094-710c10b00367n%40googlegroups.com.