```
class Solution:
# @return a string
def longestCommonPrefix(self, strs):
if len(strs)==0:
return ''
answer=[]
j=0
while True:
if j>len(strs[0])-1:
break
temp=strs[0][j]
for i in range(1,len(strs)):
if j>len(strs[i])-1 or temp!=strs[i][j]:
temp=''
break
if temp=='':
break
answer.append(temp)
j=j+1
return ''.join(answer)
```