def clean_content(contents):
ret = []
for i in range(0, len(contents) - 1):
first_str = contents[i]
second_str = contents[i + 1]
index = len(first_str) - 2
start_with = False
for j in range(index, -1, -1):
if second_str.startswith(first_str[j:]):
ret.append(first_str[:j])
start_with = True
break
if not start_with:
ret.append(first_str)
ret.append(contents[-1])
return ret
相邻字符串去重
最新推荐文章于 2024-10-03 13:36:06 发布