关于lcs的问题 [英] question about lcs

查看:90
本文介绍了关于lcs的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个代码来查找给定2个字符串的最长公共子字符串.但是,例如,如果第一个字符串是:aaabbcd,第二个字符串是aaabbfd,则为了输出,我需要获取此公共子字符串"aaabbd"(或"aaabb d").有人可以为我提供一些执行此操作的代码吗?我的代码找到aaabb作为最长的子字符串.但我希望将"d"显示为常见的子字符串.

Thanks

I need a code to find the longest common substring for given 2 strings. BUT, for example if the first string is: aaabbcd and the second is aaabbfd, for output i need to get this common substring "aaabbd" (or "aaabb d"). can someone help me with some code for doing this? my code finds the aaabb as a longest substring. but i want "d" to be shown as a common substring.

thanks

推荐答案

您可以使用常规表达式进行此操作.或者,您可以编写仅查找常见字符,然后跳过不常见字符的代码.对我来说这听起来像是功课.如果是作业,如果遇到困难,应首先与您的老师交谈.另外,如果您已经编写了代码,则应在寻求帮助时将其发布,以便我们了解您的工作.
You can probably do this with regular expresions. Or you can write code which simply finds common characters, then skips ones that are not common. This sounds homeworkish to me. If it''s an assignment, you should talk to your teacher first if you get stuck. Also, if you have code written already, you should post it when asking for help, so we can see what you''ve done.


这篇关于关于lcs的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆