简体   繁体   English

字符串中超过 1 个字母的最长公共子序列

[英]Longest common subsequence of more than 1 Letter in a string

I'm trying to find the LCS of more than one letter in two strings using a k value.我正在尝试使用k值在两个字符串中查找多个字母的 LCS。 For example, if例如,如果

k  = 3 
s1 = "AAABBBCCCDDDEEE"  
s2 = "AAACCCBBBDDDEEE" 

then the LCS would be 4 : "AAABBBDDDEEE" or "AAACCCDDDEEE" , another example is if那么 LCS 将是4 : "AAABBBDDDEEE""AAACCCDDDEEE" ,另一个例子是如果

k  = 2 
s1 = "EEDDFFAABBCC" 
s2 = "AACCDDEEBBFF" 

then the LCS would be 2 : "EEBB" , "EEFF" , "DDFF" , "DDBB" , ... and so on.那么 LCS 将是2 : "EEBB" , "EEFF" , "DDFF" , "DDBB" , ... 等等。 How would I be able to do it so that more than one character is in each cell of the table and if the characters are not equal I would have to use a sort, ie "EF" == "FE"我怎样才能做到这一点,以便表格的每个单元格中有多个字符,如果字符不相等,我将不得不使用一种排序,即"EF" == "FE"

Use std::is_permutation to find if two strings contain the same characters.使用std::is_permutation来查找两个字符串是否包含相同的字符。 To store more than one character in each "cell of the table" use std::string .要在每个“表格单元格”中存储多个字符,请使用std::string

For any questions on c++, go here .有关 c++、go 的任何问题,请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM