014 Longest Common Prefix
想法很直接 复杂度O(mn)
class Solution: # @param {string[]} strs # @return {string} def longestCommonPrefix(self, strs): n = len(strs) if n == 0: return "" if n == 1: return strs[0] while True: for i in range(0, len(strs[0])): cur = strs[0][i] for j in range(1, n): if i == len(strs[j]): return strs[j] if cur != strs[j][i]: return strs[j][0:i] return strs[0]