Compute common prefix of a [ i ] unique from its right neighbor
j = 0 NEW_LINE while ( j < min ( len ( a [ i ] ) - 1 , len ( a [ i + 1 ] ) - 1 ) ) : NEW_LINE INDENT if ( a [ i ] [ j ] == a [ i + 1 ] [ j ] ) : NEW_LINE INDENT j += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT new_prefix = a [ i ] [ 0 : j + 1 ] NEW_LINE