Search⌘ K
AI Features

Solution: Longest Common Prefix

Solution: Longest Common Prefix asks you to find the longest string shared at the start of every string in an array, returning an empty string when none is shared.

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 ...