【发布时间】:2020-11-18 00:57:58
【问题描述】:
Input 1 - 'My name is Mayank'
Input 2 - 'My will name not Mayank'
Output - 'My will name is not Mayank' or 'My will name not is Mayank'
我想组合两个字符串,它们都可能包含一些额外的单词(另一个缺少)。如果有多个输出,那么请给出任何一个。
请提供 Python 或 C++ 中的任何提示或代码。
更新 - 应保持单词的顺序,并且假设所有常见单词在两个输入中的顺序相同。
【问题讨论】:
-
你想要一个特定单词顺序的答案吗?
-
输出对我来说没有意义。你能解释一下吗?
-
@vivek_23 我的意思是单词的顺序......我可以这样回答'是 Mayank 我的名字不会'。
-
@YashShah 我问过 Mayank。
-
这听起来与“diff”算法所做的非常相似,例如 GNU diff 或 git diff:en.wikipedia.org/wiki/Diff
标签: python c++ string algorithm data-structures