Exercises/#15 Longest Common Prefix
#15

Longest Common Prefix

EasyπŸ”€ Strings
40 XP

Problem

Write a function to find the longest common prefix string amongst an array of strings. Return empty string if there is no common prefix.

Examples

Input: strs = ['flower','flow','flight']
Output: 'fl'

Input: strs = ['dog','racecar','car']
Output: ''
stringtrie
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

15 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features