Quant Memo
Coding/●●●●

Edit distance between two symbols

Asked at Two Sigma

A reference-data pipeline needs to fuzzy-match ticker symbols across vendors ("BRK.B" vs "BRKB", "VOD LN" vs "VOD.L"). The workhorse metric is Levenshtein distance: the minimum number of single-character insertions, deletions, or substitutions turning string a into string b.

a = "horse", b = "ros"
-> 3            # horse -> rorse -> rose -> ros

Compute the edit distance. Target O(ab)O(|a|\cdot|b|) time, and can you do it in O(min(a,b))O(\min(|a|,|b|)) space?

Your answer

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

More Coding questions