14.Longest Common Prefix

题目描述

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.

我的解法

解题思路

题目意思是找到最长并且一样的前缀,如果没有一样的前缀,就返回空的字符串

实现代码

高票解法

实现代码

代码分析

知识总结