Skip to content · ⁨דלג לתוכן⁩

Longest common prefix · ⁨קידומת משותפת ארוכה ביותר⁩

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.

עברית

קדמה משותפת ארוכה

החזר את המחרוזת הארוכה ביותר שמתחילה כל מילה במערך. עבור flower, flow, flight זוהי fl; אם אין שום דבר משותף, החזר "". התחל עם המילה הראשונה כניחוש והצמצם אותה מול כל מילה הבאה עד שתתאים להם כולם.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP