(self, A, B)
return C
:type A: List[List[int]]
    :type B: List[List[int]]
    :rtype: List[List[int]]
:type A: List[List[int]]
    :type B: List[List[int]]
    :rtype: List[List[int]]
: type A : List [ List [ int ]] : type B : List [ List [ int ]] : rtype : List [ List [ int ]]
def multiply(self, A, B):
    """
    :type A: List[List[int]]
    :type B: List[List[int]]
    :rtype: List[List[int]]
    """
    if A is None or B is None: return None
    m, n = len(A), len(A[0])
    if len(B) != n:
        raise Exception("A's column number must be equal to B's row number.")
    l = len(B[0])
    table_A, table_B = {}, {}
    for i, row in enumerate(A):
        for j, ele in enumerate(row):
            if ele:
                if i not in table_A: table_A[i] = {}
                table_A[i][j] = ele
    for i, row in enumerate(B):
        for j, ele in enumerate(row):
            if ele:
                if i not in table_B: table_B[i] = {}
                table_B[i][j] = ele
    C = [[0 for j in range(l)] for i in range(m)]
    for i in table_A:
        for k in table_A[i]:
            if k not in table_B: continue
            for j in table_B[k]:
                C[i][j] += table_A[i][k] * table_B[k][j]
    return C
def multiply ( self , A , B ) : if A is None or B is None : return None m , n = len ( A ) , len ( A [ 0 ] ) if len ( B ) != n : raise Exception ( "A's column number must be equal to B's row number." ) l = len ( B [ 0 ] ) table_A , table_B = { } , { } for i , row in enumerate ( A ) : for j , ele in enumerate ( row ) : if ele : if i not in table_A : table_A [ i ] = { } table_A [ i ] [ j ] = ele for i , row in enumerate ( B ) : for j , ele in enumerate ( row ) : if ele : if i not in table_B : table_B [ i ] = { } table_B [ i ] [ j ] = ele C = [ [ 0 for j in range ( l ) ] for i in range ( m ) ] for i in table_A : for k in table_A [ i ] : if k not in table_B : continue for j in table_B [ k ] : C [ i ] [ j ] += table_A [ i ] [ k ] * table_B [ k ] [ j ] return C