You are viewing a single comment's thread. Return to all comments →
I quite liked this Python, but it turned out too slow:
from collections import Counter def commonChild(s1, s2): ctable = Counter() for i in range(len(s1)): for j in range(len(s2)): if s1[i] == s2[j]: ctable[(i, j)] = 1 + ctable[(i-1, j-1)] else: a, b = ctable[(i, j-1)], ctable[(i-1, j)] if a or b: ctable[(i, j)] = max(a, b) values = list(ctable.values()) return values[-1] if values else 0
Seems like cookies are disabled on this browser, please enable them to open this website
Common Child
You are viewing a single comment's thread. Return to all comments →
I quite liked this Python, but it turned out too slow: