gpt4 book ai didi

text - 查找最长可能重复字符串的实用程序

转载 作者:行者123 更新时间:2023-12-04 21:26:44 24 4
gpt4 key购买 nike

是否有任何工具或实用程序或 perl/python 脚本可以在大型文本文件中找到最长的重复子字符串并打印这些模式以及每个模式出现的次数?

最佳答案

http://en.wikipedia.org/wiki/Longest_repeated_substring_problem :

The longest repeated substring problem is finding the longest substring of a string that occurs at least twice. This problem can be solved in linear time and space by building a suffix tree for the string, and finding the deepest internal node in the tree


  • python 中的后缀树(有点过时,但..):http://hkn.eecs.berkeley.edu/~dyoo/python/suffix_trees/
  • 带有进一步说明的 Javascript 实现:http://www.allisons.org/ll/AlgDS/Tree/Suffix/
  • 关于text - 查找最长可能重复字符串的实用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2146768/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com