strs은 단어가 담긴 배열입니다.
공통된 시작 단어(prefix)를 반환해주세요.
예를 들어
strs = ['start', 'stair', 'step']
return은 'st'
strs = ['start', 'wework', 'today']
return은 ''
def get_prefix(strs):
prefix = ''
if not strs:
return prefix
for i in range(len(strs[0])):
for j in range(len(strs)):
if strs[0][i] == strs[j][i]:
if j == (len(strs)-1):
prefix += strs[0][i]
if strs[0][i] != strs[j][i]:
return prefix
return prefix
get_prefix(['flower', 'flue', 'fly'])