当你把光标放在a前面]
,)
或者}
你输入那个字符,而不是插入它时,vscode只是移过那个字符,]*cursor here*
而不是生成]*cursor here*]
.因此,每次我需要插入一个右括号时,我需要移动))))
到键入它的末尾,而不是直接键入它.那么有没有办法禁用此行为(不禁用括号自动完成)?
我需要满足以下条件的所有字符序列:
因此,如果输入字符串是:KAKAMNENENELIOLELIONEM$
输出将是:
(KA, 2)
(NE, 4)
(LIO, 2)
Run Code Online (Sandbox Code Playgroud)
它还需要很快,它应该能够在合理的时间内解决 1000 个字符的长字符串。
编辑此后缀树-创建库(Python-Suffix-Tree),我制作了一个程序,该程序给出了一些错误的结果。
我将此函数添加到 suffix_tree.py 中的 SuffixTree 类:
def get_repeated_substrings(self):
curr_index = self.N
values = self.edges.values()
values = sorted(values, key=lambda x: x.dest_node_index)
data = [] # index = edge.dest_node_index - 1
for edge in values:
if edge.source_node_index == -1:
continue
top = min(curr_index, edge.last_char_index)
data.append([edge.source_node_index,
self.string[edge.first_char_index:top+1]])
repeated_substrings = {}
source_node_indexes = …
Run Code Online (Sandbox Code Playgroud)