The simpliest way, i believe is to do something like this:
from itertools import takewhile def find_lcp(s: List[str]) -> str: t = len(list(takewhile(lambda x: len(x)==1, map(set,zip(*s))))) return s[0][:t]