Longest Common Prefix Problem
Longest Common Prefix Problem — ExecCode Easy DSA Practice
Solve the Longest Common Prefix problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "".
Examples
Input strs = ["flower", "flow", "flight"]; Output "fl". Input strs = ["dog", "racecar", "car"]; Output "". Input strs = ["interview", "internet", "interval"]; Output "inter"
Constraints
1 <= strs.length <= 200 0 <= strs[i].length <= 200 strs[i] consists of only lowercase English letters
Practice Longest Common Prefix free on ExecCode. Browse DSA problems, topic map, and placement guides.