Longest Common Subsequence
Mediumjavapythonccppjavascript
Given two strings, find the length of their longest subsequence that appears in both strings in the same relative order (characters need not be contiguous).
Input Format
The first line contains string A. The second line contains string B. Both consist of lowercase English letters with no spaces.
Output Format
Print the length of the longest common subsequence.
Example 1
Input
abcde ace
Output
3
Explanation: "ace" is a common subsequence of both strings.
- 1 <= length of A, B <= 1000