LCS 6
Time limit1sMemory limit8 MB
Given two uppercase strings of up to 50000 characters, print the length of their longest common subsequence.
- Level
Hard8 of 10
- Topics
- String, Dynamic programming, Binary search
- Solved
- No attempts yet
Problem
The LCS (Longest Common Subsequence) problem asks, given two sequences, for the longest sequence that is a subsequence of both.
For example, the LCS of ACAYKP and CAPCAK is ACAK.
Input
The first and second lines give two strings. Each string consists only of uppercase letters and is at most 50000 characters long.
Output
Print the length of the LCS of the two strings given as input on the first line.