Untitled

mail@pastecode.io avatar
unknown
python
20 days ago
576 B
5
Indexable
Never
def solution(a, b, queries):
    result = []

    def count_combinations(target):
        combinations = 0
        
        for num_a in a:
            for num_b in b:
                if num_a + num_b == target:
                    combinations += 1
        
        return combinations

    for query in queries:
        if query[0] == 0:
            # if query[i] == 0, add to b
            _, i, x = query
            b[i] += x
        else:
            # if query[i] == 1, twoSum
            _, x = query
            result.append(count_combinations(x))

    return result
Leave a Comment