"tea" is a subsequence of "theatre", but "eat" is not.
You are given two strings, first and second. Find the length of the longest string that is a subsequence of both. If they share no characters, return 0.first="bicycle", second="circle" → 4
One longest shared subsequence is "icle": the letters i, c, l, e appear in this order in both strings. There is no way to line up five shared letters.
first="kayak", second="kayak" → 5
The strings are equal, so the whole string is shared, length 5.
first="xyz", second="abc" → 0
There are no common letters, so the answer is 0.
first.length, second.length ≤ 1000first="bicycle", second="circle"
4
Run checks the first 3 tests in your browser. Submit checks all 141 tests on the server, hidden ones included.