1981. Minimize the Difference Between Target and Chosen Elements
Last updated
Last updated
https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements
You are given an m x n
integer matrix mat
and an integer target
.
Choose one integer from each row in the matrix such that the absolute difference between target
and the sum of the chosen elements is minimized.
Return the minimum absolute difference.
The absolute difference between two numbers a
and b
is the absolute value of a - b
.
Example 1:
Example 2:
Example 3:
Constraints:
m == mat.length
n == mat[i].length
1 <= m, n <= 70
1 <= mat[i][j] <= 70
1 <= target <= 800