Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
zip & set solution in Clear category for Longest Common Prefix by kdim
def longest_prefix(arr: list[str]) -> str:
n, a = 0, list(zip(*arr))
while a and len(set(a.pop(0))) == 1:
n += 1
return arr[0][:n]
Oct. 7, 2023
Comments: