Class Solution
java.lang.Object
g0001_0100.s0014_longest_common_prefix.Solution
14 - Longest Common Prefix.<p>Easy</p>
<p>Write a function to find the longest common prefix string amongst an array of strings.</p>
<p>If there is no common prefix, return an empty string <code>""</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> strs = [“flower”,“flow”,“flight”]</p>
<p><strong>Output:</strong> “fl”</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> strs = [“dog”,“racecar”,“car”]</p>
<p><strong>Output:</strong> ""</p>
<p><strong>Explanation:</strong> There is no common prefix among the input strings.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= strs.length <= 200</code></li>
<li><code>0 <= strs[i].length <= 200</code></li>
<li><code>strs[i]</code> consists of only lower-case English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
longestCommonPrefix
-