Given two strings s1 and s2, find the length of their longest common subsequence (LCS). If there is no common subsequence, return 0.
The strings are composed of lower case English alphabets.
A subsequence of a string is a string that can be derived by deleting some or no characters such that the order of the remaining characters remain the same.
s1: "workattech"
s2: "branch"
Result: 4
Explanation: Longest common subsequence is "rach"
The first line contains an integer âTâ denoting the number of test cases.
For each test case, the input has two lines:
For each test case, the output contains a line with one integer denoting the length of the longest common subsequence.
4
workattech
branch
helloworld
playword
hello
hello
abc
def
4
5
5
0
1 <= T <= 10
1 <= s1.length, s2.length <= 3000