Longest Common Subsequence

hard

300 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
Discussion

No comments yet — ask a question or share a hint.

Log in to join the discussion.

Log in to submit a solution.