Search⌘ K
AI Features

Solution: Longest Common Prefix

Solution: Longest Common Prefix asks you to examine an array of strings and return the longest string prefix shared by every element, or an empty string when none exists.

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:

  • 1≤1 \leq ...