Skip to content · ⁨Passer au contenu⁩

Longest common prefix · ⁨Plus long préfixe commun⁩

English

Longest common prefix

Return the longest string that starts every word in the array. For flower, flow, flight it's fl; if there's nothing in common, return "". Start with the first word as a guess and shrink it against each next word until it fits them all.

Français

Préfixe commun le plus long

Retournez la plus longue chaîne qui commence chaque mot dans le tableau. Pour flower, flow, flight c'est fl ; s'il n'y a rien en commun, retournez "". Commencez avec le premier mot comme hypothèse et réduisez-le face à chaque mot suivant jusqu'à ce qu'il corresponde à tous.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP