2363. Merge Similar Items

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2363

class Solution:
    def mergeSimilarItems(
        self, items1: List[List[int]], items2: List[List[int]]
    ) -> List[List[int]]:
        cnt = Counter()
        for v, w in chain(items1, items2):
            cnt[v] += w
        return sorted(cnt.items())