class Solution(object):
def longestCommonPrefix(self, strs):
shortest_string = ""
for member in strs:
if (shortest_string == "") or (len(member) < len(shortest_string)):
shortest_string = member
if shortest_string == "":
return ""
common_pre = ""
shortest_string_length = len(shortest_string)
for pre_length in range(1, shortest_string_length + 1) :
common_pre_temp = shortest_string[0:pre_length]
for member in strs:
if common_pre_temp != member[0:pre_length]:
return common_pre
common_pre = common_pre_temp
return common_pre
"""
:type strs: List[str]
:rtype: str
"""
def longestCommonPrefix(self, strs):
shortest_string = ""
for member in strs:
if (shortest_string == "") or (len(member) < len(shortest_string)):
shortest_string = member
if shortest_string == "":
return ""
common_pre = ""
shortest_string_length = len(shortest_string)
for pre_length in range(1, shortest_string_length + 1) :
common_pre_temp = shortest_string[0:pre_length]
for member in strs:
if common_pre_temp != member[0:pre_length]:
return common_pre
common_pre = common_pre_temp
return common_pre
"""
:type strs: List[str]
:rtype: str
"""