Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
take zipped while all equal solution in Clear category for Longest Common Prefix by Phil15
import itertools as it
all_equal = lambda x: len(set(x)) == 1
def longest_prefix(arr: list[str]) -> str:
return ''.join(x[0] for x in it.takewhile(all_equal, zip(*arr)))
Oct. 7, 2023
Comments: