Ldef longestCommonPrefix(self, strs): # write your code here if ‘‘ in strs or strs == []: return ‘‘ s, n = ‘‘, ‘‘ for j in range(min([len(i) for i in strs])): for i in range(len(strs)): s += strs[i][j] if s == s[0]*len(s): n += s[0] s = ‘‘ return n
Ldef longestCommonPrefix(self, strs): # write your code here if ‘‘ in strs or strs == []: return ‘‘ s, n = ‘‘, ‘‘ for j in range(min([len(i) for i in strs])): for i in range(len(strs)): s += strs[i][j] if s == s[0]*len(s): n += s[0] s = ‘‘ return n
原文:https://www.cnblogs.com/tingway/p/8544003.html