1981. Minimize the Difference Between Target and Chosen Elements

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1981

class Solution:
    def minimizeTheDifference(self, mat: List[List[int]], target: int) -> int:
        f = {0}
        for row in mat:
            f = set(a + b for a in f for b in row)
        return min(abs(v - target) for v in f)