Python Quickest O(N*min(length of Strings))


#1
class Solution:
# @param A : list of strings
# @return a strings
def longestCommonPrefix(self, A):
    substring=[]
    if(len(A)==0):
        return ""
    minLen=len(A[0])
    for i in A:
        if len(i)<minLen:
            minLen=len(i)
    matching=1       
    for i in range(minLen):
        if matching==0:
            break
        c=A[0][i]
        for j in A:
            if (c!=j[i]):
                matching=0
                break
        if(matching==1):
            substring.append(c)
    return "".join(substring)