Longest Shared Thread
Medium · Longest Shared Thread
A subsequence of a string is what remains after crossing out any number of its characters (possibly none) while keeping the rest in their original order. For example, `"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`.…
Solve the problem →