String STL Doubt

If we define a magic number between two strings A and B as longest common subsequence of A and B. then what would be the magic number for a pair of string A=”AGGTAB” , B=”GXTXAYB”?

4

5

7

6

@Kinjal answer will be 4

mujhe question hi samajh nai aya.

@Kinjal you just have to tell the longest common subsequence of both the strings
GTAB in this case

isme, GTAB ke beech meh XXY hai. So, I don’t get it.

@Kinjal you have to find subsequence not substring.
substring needs to be continuous while subsequence do not

1 Like

subsequences of abcd can be abc, ad, acd … while substring abcd , bcd, cd …

1 Like

Got it.
Bhaiya, I don’t know about KMP, can you give a some sort of understanding about KMP?

@Kinjal here refer this

I felt very hard to understand. But, okay. Thanks.