Sabbir is also comparing two barcodes (as strings) and needs their longest common subsequence for a fuzzy-matching feature. Given two strings A and B, print the length of their longest common subsequence.
Input
Two strings A and B.
Output
Length of LCS.
Constraints
1 ≤ |A|,|B| ≤ 2000
Sample Input
abcde ace
Sample Output
3
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.