题解 | #最长公共前缀#
最长公共前缀
https://www.nowcoder.com/practice/9d6f66db23544260aba0c04f9aeb4a45
class Solution: def longestCommonPrefix(self , strs ): res = '' for items in zip(*strs): if len(set(items)) == 1: res += items[0] else: break return res
最长公共前缀
https://www.nowcoder.com/practice/9d6f66db23544260aba0c04f9aeb4a45
class Solution: def longestCommonPrefix(self , strs ): res = '' for items in zip(*strs): if len(set(items)) == 1: res += items[0] else: break return res
相关推荐