Given two strings, 'S' and 'T' with lengths 'M' and 'N', find the length of the 'Longest Common Subsequence'.
For a string 'str'(per se) of length K, the subsequences are the strings containing characters in the same relative order as they are present in 'str,' but not necessarily contiguous. Subsequences contain all the strings of length varying from 0 to K.
Example :
Subsequences of string "abc" are: ""(empty string), a, b, c, ab, bc, ac, abc.
Input format :
The first line of input contains the string 'S' of length 'M'.
The second line of the input contains the string 'T' of length 'N'.
Output format :
Return the length of the Longest Common Subsequence.
Constraints :
0 <= M <= 10 ^ 3
0 <= N <= 10 ^ 3
Time Limit: 1 sec
The task is to find the length of the longest common subsequence between two given strings.
A subsequence is a string that can be derived from another string by deleting some or no characters without c...read more
Let the two strings be x and y.
Let x(i) be the substring of x from index 0 to index i.
Let c[i, j] be the length of the longest common subsequence of strings x(i) and y(j).
Then the recurre...read more
Let the two strings be x and y.
Let x(i) be the substring of x from index 0 to index i.
Let c[i, j] be the length of the longest common subsequence of strings x(i) and y(j).
Then the recurr...read more
In each iteration of the outer loop in iterative ‘DP’ we only, need values from all columns of the previous row so instead of making an ('M' + 1) * ('N' + 1) sized array (referred to as...read more
Top AVL Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Reviews
Interviews
Salaries
Users/Month