给定两个字符串 str1 和 str2,我有一个匹配列表,将共享子字符串描述为 [str1_beg, str1_end, str2_beg, str2_end] 形式的间隔。我想删除冗余匹配,其中匹配中的 str1_beg、str1_end 和 str2_beg、str2_end 嵌入到其他匹配中。
最佳答案
对于每个 [beg_index, end_index] 找到 [beg_index_new, end_index_new] 并删除满足 end_index < end_index_new 和 beg_index >= beg_index_new 的。
那是 O(n^2)
关于string - 如何删除两个字符串之间的冗余匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12420296/