思路描述
给k个字符串,求出他们的最长公共前缀(LCP)
样例
在 “ABCD” “ABEF” 和 “ACEF” 中, LCP 为 “A”
思路
- 法一:用python的zip函数解决
- 法二:两两比较
代码
class Solution:
"""
法一:使用zip函数
@param: strs: A list of strings
@return: The longest common prefix
"""
def longestCommonPrefix(self, strs):
# write your code here
if strs is None