字符串中子字符串的组合
如何找到给定字符串中一组字符串的所有可能组合?
strings = ["ab","aa","ab","bb","ba","aba","aab"]
given_string = "abaababbab"
必须返回:
[
["ab","aa","ba","bb","ab],
["ab","aab","ab","ba","bab"]
["aba","aba","bb","ab"]
]
How can I find all possible combinations of a set of strings in a given string?
strings = ["ab","aa","ab","bb","ba","aba","aab"]
given_string = "abaababbab"
has to return:
[
["ab","aa","ba","bb","ab],
["ab","aab","ab","ba","bab"]
["aba","aba","bb","ab"]
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个粗略的想法可能是这样的:
这会给你:
我不确定你是否在这里寻找重复项。如果你不小心的话,你可能会遇到计算复杂的问题,因为这类事情使得 DNA 测序变得异常计算密集。
A rough idea might be something like this:
This would give you:
I'm not sure if you're hunting for duplicates here or not. You may end up in a computationally complex problem if you're not careful as this sort of thing is what makes DNA sequencing extraordinarily compute-intensive.
以下:
会给你:
我不明白为什么你的答案中有
["ab","aab","ab","ba","bab"]
。The following:
will give you:
I don't get why you have
["ab","aab","ab","ba","bab"]
in your answer.