题解 | #最长公共前缀#
最长公共前缀
http://www.nowcoder.com/practice/28eb3175488f4434a4a6207f6f484f47
# # # @param strs string字符串一维数组 # @return string字符串 # class Solution: def longestCommonPrefix(self , strs ): # write code here length = len(strs) if strs == '' or (length == 0): return "" pre = strs[0] i = 1 while (i < len(strs)): while(strs[i].find(pre) == -1): pre = pre[0:len(pre)-1] i=i+1 return pre