找所有字符串的最长前缀公共子串。
Write a function to find the longest common prefix string amongst an array of strings.
没难点。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | class Solution(object):     def longestCommonPrefix(self, strs):         """         :type strs: List[str]         :rtype: str         """         lens = len(strs)         if lens <= 0 :             return ""         rt = ""         for i in range(0, len(strs[0])) :             flag = True             for str in strs :                 if i >= len(str) or str[i] != strs[0][i] :                     flag = False                     break             if flag :                 rt += strs[0][i]             else :                 break         return rt | 
随便挂一下。
【LeetCode】14. Longest Common Prefix
				
					