双列表匹配优化问询:错位重复元素的列对齐方案需求
双列表元素错位匹配优化方案需求
输入示例
input1 = ["order", "name", "age", "soul", "test", "chill", "thym", "transport", "lim"] input2 = ["order", "age", "soul", "chill", "thym", "exe", "test", "lim"]
期望输出
order order name - age age soul soul test - chill chill thym thym transport - - exe - test lim lim
匹配规则
- 元素仅存在于input1中时,输出「元素 -」
- 元素仅存在于input2中时,输出「- 元素」
- 元素同时存在于两列表但位置不同(如示例中的
test),需分别输出「test -」和「- test」 - 最终输出要求「-」的数量最少
当前问题与需求
目前仅能处理单列表独有的元素,无法解决错位重复元素的匹配问题,寻求最优实现方案。
内容的提问来源于stack exchange,提问作者Kepler452B
相关产品推荐
相关产品推荐

