Longest Common Prefix

Try to solve the Longest Common Prefix problem.

Statement

Given an array of strings, strs, write a function to find the longest common prefix string in strs. If there is no common prefix, return an empty string, "".

Constraints:

  • 11 \leq strs.length 200\leq 200

  • 00 \leq strs[i].length 200\leq 200

  • strs[i] consists of only lowercase English letters.

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.