Shared Playlist History
mediumTwo friends compare their listening histories. Each history is a string where every character is a track code, in the order it was played. A shared run is a sequence of track codes that appears in both histories in the same relative order — gaps are fine, reordering is not.
Given histories a and b, return the length of the longest shared run.
Example 1
in a = "abcde", b = "ace"
out 3
Both played "a", then "c", then "e" in that order.
Example 2
in a = "abc", b = "def"
out 0
No track code appears in both.
Constraints
- · 0 <= len(a), len(b) <= 50
- · lowercase track codes only
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.