+ 82

[ASSIGNMENT] String Manipulation

Find the longest common subsequence in two string for example input1 : <m a n a g e r> input2: <d a n g e r> output : <a n g e r> which length is 5 the longest common subsequence is anger any language is welcome least complex solution will be appreciated A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, “abc”, “abg”, “bdf”, “aeg”, ‘”acefg”, .. etc are subsequences of “abcdefg”. So a string of length n has 2^n different possible subsequences.

8th Feb 2018, 1:13 PM
GAWEN STEASY
GAWEN STEASY - avatar
58 Answers
8th Feb 2018, 5:50 PM
LukArToDo
LukArToDo - avatar
+ 44
1)manager naagr //output must be "aagr" or "nagr" or both of these 2)aaab baaa //output must be aaa 3)pool loop //output must be oo 4)bdrcve , bcvde //output must be bcve https://code.sololearn.com/c88Qgivl7e6V/?ref=app
8th Feb 2018, 2:09 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
9th Feb 2018, 9:49 AM
🌛DT🌜
🌛DT🌜 - avatar
9th Feb 2018, 11:31 AM
Youssef Ouamou
Youssef Ouamou - avatar
+ 19
It feels great when you can solve problems in newly learnt language https://code.sololearn.com/cpXUc3KIGp0K/?ref=app
9th Feb 2018, 10:17 AM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
+ 18
thanks @Asmaa I'm just a beginner so know only two languages but will try to learn more 😊😊 good luck to you too for your dreams
8th Feb 2018, 6:11 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 17
@swim , U can see the comments on code of Yerucham //a long discussion is present there , U will understand the challenge easily
9th Feb 2018, 11:52 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 17
Congratulations for your quiz creation master badge 👍😉
27th Feb 2018, 4:16 AM
tooselfish
tooselfish - avatar
+ 16
@ GAWEN STEASY, you are welcome 👍😉 and if you like this comment, i am going to delete both 😊
27th Feb 2018, 10:44 AM
tooselfish
tooselfish - avatar
+ 14
Hello, everyone! Here is my python code for this challenge. Please leave your comment and upvote! https://code.sololearn.com/c7QNrM3iJt4M/
8th Feb 2018, 9:59 PM
Pedro Maimere
Pedro Maimere - avatar
10th Feb 2018, 3:37 PM
Mazin Ayash
Mazin Ayash - avatar
8th Feb 2018, 7:43 PM
David Akhihiero
David Akhihiero - avatar
+ 12
The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from the longest common substring problem: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences. The longest common subsequence problem is a classic computer science problem, the basis of data comparison programs such as the diff utility, and has applications in bioinformatics. It is also widely used by revision control systemssuch as Git for reconciling multiple changes made to a revision-controlled collection of files. https://en.m.wikipedia.org/wiki/Longest_common_subsequence_problem I made this best to understand to all what is lcs problem when the challenge is over I will mark a best answer to that code
9th Feb 2018, 7:03 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 12
Here is my try: (taking into consideration contiguous subsequence) https://code.sololearn.com/cDQIvyPz9lJl/?ref=app
11th Feb 2018, 10:51 PM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 11
brute forcing always works..😉😀.. printing all if multiple subsequence with same length https://code.sololearn.com/cremhZN2Iw7G/?ref=app
10th Feb 2018, 9:29 AM
Zoetic_Zeel
Zoetic_Zeel - avatar
+ 11
thanks @tooselfish😊😊
27th Feb 2018, 9:36 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 10
@Swim you are on discord then I will able to give you a perfect answer because it follows an algorithm of matrix by which the longest common subsequence is find
9th Feb 2018, 11:53 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 10
#edited If it is truly finding comman substrings, it should not allow another characters between subsequent members of substring...Then for "manager" and "danger" output should be "ger" only...some other examples try with your codes.. 1) "loop" and "pool" -->"oo" 2)"ahopebhope" and "chopedhope" -->hope 3)"pqrs" and "srqp" --> no subsequence is matching following code is giving the same outputs if matching substring length is more then 1 https://code.sololearn.com/cBOpN9UlvlUb/?ref=app
9th Feb 2018, 2:04 PM
Zoetic_Zeel
Zoetic_Zeel - avatar
+ 10
These types of challenges are fun. It helps me alot.
10th Feb 2018, 5:42 PM
Pravin Pandey
Pravin Pandey - avatar
+ 10
@Debasish yes it can handel multiple match, but the challenge is to get the longest so no need for other matching that's why i don't include multiple matching. thank you for your notice.
12th Feb 2018, 8:38 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar