Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Example 1:
Input: ["flower","flow","flight"] Output: "fl"
Example 2:
Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings.
Note:
All given inputs are in lowercase letters a-z.

本文介绍了一种方法,用于在字符串数组中查找最长的共同前缀。如果不存在共同前缀,则返回空字符串。通过两个例子详细说明了该方法的应用:例一输入为[flowerflowflight],输出为fl;例二输入为[dogracecarcar],由于没有共同前缀,输出为空字符串。
300

被折叠的 条评论
为什么被折叠?



