<doocs>0720.Longest Word in Dictionary_1.py
def longestWord( words: List[str]) -> str:
    cnt, ans = 0, ''
    s = set(words)
    for w in s:
        n = len(w)
        if all(w[:i] in s for i in range(1, n)):
            if cnt < n:
                cnt, ans = n, w
            elif cnt == n and w < ans:
                ans = w
    return ans
def sample_funcname ( var_0 : List [ str ] ) -> str :
    var_4 , var_6 = 0 , ''
    var_8 = set ( var_0 )
    for var_9 in var_8 :
        var_11 = len ( var_9 )
        if all ( var_9 [ : var_13 ] in var_8 for var_13 in range ( 1 , var_11 ) ) :
            if var_4 < var_11 :
                var_4 , var_6 = var_11 , var_9
            elif var_4 == var_11 and var_9 < var_6 :
                var_6 = var_9
    return var_6
