题目简述:
Write a function to find the longest common prefix string amongst an array of strings.
解题思路:
class Solution:
# @return a string
def longestCommonPrefix(self, strs):
if strs == []:
return ''
minl = 99999
for i in strs:
if len(i) < minl:
minl = len(i)
pre = ''
for i in range(minl):
t = strs[0][i]
for j in range(1,len(strs)):
if t != strs[j][i]:
return pre
pre += t
return pre