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.

ไทย

พrefix ที่ยาวที่สุดร่วมกัน

กลับสตริงที่ยาวที่สุดที่ เริ่มต้น ทุกคำในอาร์เรย์ สำหรับ flower, flow, flight คำตอบคือ fl; หากไม่มีอะไรเหมือนกัน ให้คืนค่า "" เริ่มด้วยคำแรกเป็นคำเดาและหดมันลงทีละคำจนกว่าจะเข้ากับทั้งหมด

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP