Problem :

https://leetcode.com/problems/longest-common-prefix/description/


My Solution :

class Solution:
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
if not strs:
return ''
word = strs[0]
for i in range(len(word)):
for s in strs[1:]:
if i > len(s)-1 or s[i] != word[i]:
return word[:i]
return word


Comment :

너비 우선 탐색 전략. Edge Case 조심.