574. String Test
0
Medium
Albela is preparing for a coding test on Strings. While revising strings, he encountered a question that required him to find the length of the longest common subsequence between two given strings, s1 and s2. If there is no common subsequence, the expected output is 0. Albela needs your help to solve this question and prepare effectively.
A subsequence of a string is a new string formed by deleting some characters (possibly none) from the original string, without changing the relative order of the remaining characters.
For example, "ace" is a subsequence of "abcde".
A common subsequence of two strings is a subsequence that is present in both strings.
A common subsequence of two strings is a subsequence that is present in both strings.
Input Format
Take two strings, S1 and S2, as input.
Output Format
Print the length of the longest common subsequence.
Example
Input
abcde
ace
Output
3
Constraints
1 <= s1.length(), s2.length() <= 1000
Loading...
View Submissions
Console