|
| 1 | +<h2><a href="https://leetcode.com/problems/longest-common-prefix/">14. Longest Common Prefix</a></h2><h3>Easy</h3><hr><div><p>Write a function to find the longest common prefix string amongst an array of strings.</p> |
| 2 | + |
| 3 | +<p>If there is no common prefix, return an empty string <code>""</code>.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre><strong>Input:</strong> strs = ["flower","flow","flight"] |
| 9 | +<strong>Output:</strong> "fl" |
| 10 | +</pre> |
| 11 | + |
| 12 | +<p><strong class="example">Example 2:</strong></p> |
| 13 | + |
| 14 | +<pre><strong>Input:</strong> strs = ["dog","racecar","car"] |
| 15 | +<strong>Output:</strong> "" |
| 16 | +<strong>Explanation:</strong> There is no common prefix among the input strings. |
| 17 | +</pre> |
| 18 | + |
| 19 | +<p> </p> |
| 20 | +<p><strong>Constraints:</strong></p> |
| 21 | + |
| 22 | +<ul> |
| 23 | + <li><code>1 <= strs.length <= 200</code></li> |
| 24 | + <li><code>0 <= strs[i].length <= 200</code></li> |
| 25 | + <li><code>strs[i]</code> consists of only lowercase English letters.</li> |
| 26 | +</ul> |
| 27 | +</div> |
0 commit comments