```
class Solution(object):
def longestCommonPrefix(self, strs):
if len(strs) == 0:
return ""
n = 0
ans = True
while ans:
if len(strs[0]) < n:
break
s = strs[0][0:n]
for i in xrange(0, len(strs)):
if strs[i][0:n] != s:
ans = False
break
if ans == True:
n += 1
if n == 0:
return ""
else:
return strs[0][0:n-1]
```