예외처리 할 것들이 많았습니다.

class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        ans = ""
        length = len(strs)
        
        if(length == 0):
            return ans
        elif(length == 1):
            for i in range(len(strs[0])):
                ans += strs[0][i]
        
        leng = 1000
        for i in range(length):
            if(len(strs[i]) < leng):
                leng = len(strs[i])
        

        for i in range(leng):
            for j in range(1, length):
                if(strs[0][i] == strs[j][i]):
                    if(j == length -1):
                        ans += strs[0][i]
                    else:
                        continue
                else:
                    return ans
                
        return ans
        

Posted by 공놀이나하여보세
,