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
Posted tingway
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了78.公共子串相关的知识,希望对你有一定的参考价值。
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
以上是关于78.公共子串的主要内容,如果未能解决你的问题,请参考以下文章