~/algor $ cat problems/dp-umumiy-qism-ketma-ketlik
Longest common subsequence
Medium
1000 ms
128 MB
58%
Two strings $s$ and $t$ are given. A string obtained from a string by deleting some letters (without changing the order) is called its subsequence. Find the length of the longest string that is a subsequence of both $s$ and $t$.
Input
The first line contains the string $s$, the second line contains the string $t$.
Output
One integer — the length of the longest common subsequence.
Note
$1 \le |s|, |t| \le 1000$
the strings consist only of lowercase Latin letters (a–z)
Examples
Input #1
dasturlash qaldirgoch
Output #1
3
Input #2
abc xyz
Output #2
0