logo
Interview
    Interview Guide
    Coding Problems List
Sponsored: Coursera
Problems

Longest Common Prefix

Problem

Given k strings, find the longest common prefix (LCP).

Example

For strings "ABCD", "ABEF" and "ACEF", the LCP is "A"

For strings "ABCDEFG", "ABCEFG" and "ABCEFA", the LCP is "ABC"

Online Judge