Quant Memo
Coding/●●●●

Longest shared pattern between two signal streams

Two models each output a sequence of daily calls, like "up" / "dn" / "flat". You want the length of the longest common subsequence: the longest ordered pattern that appears in both (keeping order, but the matching days need not be consecutive in either stream).

a = ["up", "dn", "up", "dn", "up"]
b = ["dn", "up", "up", "dn"]
-> 3        # e.g. "dn", "up", "dn"

Return the length of the longest common subsequence in O(m*n) time.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions