<jupyter_start><jupyter_text>Using divide and conquer<jupyter_code>def longestCommonPrefix(strs):
    def matchHelper(str1,str2):
        strLen = len(str2) if len(str1) > len(str2) else len(str1)
        ans = []
        for i in range(strLen):
            if str1[i] == str2[i]:
                ans.append(str1[i])
            else:
                break
            pass
        return "".join(ans)
        
    def usingDivideConquer(innerStrs,i,j):
        calc = abs(j - i + 1)
        if calc == 1:
            return innerStrs[i]
        elif calc > 2:
            k = (i + j)//2
            temp1 = usingDivideConquer(innerStrs,i,k)
            temp2 = usingDivideConquer(innerStrs,k+1,j)
            return matchHelper(temp1,temp2)
        elif abs(j - i + 1) == 2:
            return matchHelper(innerStrs[i],innerStrs[j])
            pass
        elif abs(j - i + 1) < 2:
            return ""
            pass
        else:
            return ""
        
    return usingDivideConquer(strs,0,len(strs)-1)
        
longestCommonPrefix(["flower","flow","flight"])<jupyter_output><empty_output><jupyter_text>Using Horizontal Scanning<jupyter_code>def longestCommonPrefix(strs):
    if "" in strs:
        return ""
    if len(strs) == 1:
        return strs[0]
    
    def matchHelper(str1,str2):
        strLen = len(str2) if len(str1) > len(str2) else len(str1)
        ans = []
        for i in range(strLen):
            if str1[i] == str2[i]:
                ans.append(str1[i])
            else:
                break
            pass
        return "".join(ans)
        
    ans = matchHelper(strs[0],strs[1])
    check = True
    for val in strs[2:]:
        ans = matchHelper(ans,val)
    return ans    
longestCommonPrefix(["flower","flow","flight"])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12326485285952249, 'fraction_numerical': 0.02109938922820655, 'mean_word_length': 1.8200312989045384, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '428755', 'license': 'MIT', 'n_tokens_mistral': 619, 'n_tokens_neox': 596, 'n_words': 119, 'path': '014_Longest_Common_Prefix.ipynb', 'repo_name': 'NikhilAshodariya/LeetCode', 'size': '1801'}