Longest Common Subsequence
hard300 pts · Time limit 3000 ms · Memory limit 512 MB · Leaderboard · dp,strings
Given two strings A and B, print the length of their longest common subsequence.
Input Format
Line 1: string A.
Line 2: string B.
Output Format
A single integer: the LCS length.
Constraints
1 <= |A|, |B| <= 2000
Sample 1
Input
abcde ace
Output
3
Sample 2
Input
abc abc
Output
3
Log in to submit a solution.