3402. Minimum Operations to Make Columns Strictly Increasing Easy
1/**
2 * [3402] Minimum Operations to Make Columns Strictly Increasing
3 *
4 * You are given a m x n matrix grid consisting of non-negative integers.
5 * In one operation, you can increment the value of any grid[i][j] by 1.
6 * Return the minimum number of operations needed to make all columns of grid strictly increasing.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">grid = [[3,2],[1,3],[3,4],[0,1]]</span>
11 * Output: <span class="example-io">15</span>
12 * Explanation:
13 *
14 * To make the 0^th column strictly increasing, we can apply 3 operations on grid[1][0], 2 operations on grid[2][0], and 6 operations on grid[3][0].
15 * To make the 1^st column strictly increasing, we can apply 4 operations on grid[3][1].
16 * <img alt="" src="https://assets.leetcode.com/uploads/2024/11/10/firstexample.png" style="width: 200px; height: 347px;" /></div>
17 * <strong class="example">Example 2:
18 * <div class="example-block">
19 * Input: <span class="example-io">grid = [[3,2,1],[2,1,0],[1,2,3]]</span>
20 * Output: <span class="example-io">12</span>
21 * Explanation:
22 *
23 * To make the 0^th column strictly increasing, we can apply 2 operations on grid[1][0], and 4 operations on grid[2][0].
24 * To make the 1^st column strictly increasing, we can apply 2 operations on grid[1][1], and 2 operations on grid[2][1].
25 * To make the 2^nd column strictly increasing, we can apply 2 operations on grid[1][2].
26 * <img alt="" src="https://assets.leetcode.com/uploads/2024/11/10/secondexample.png" style="width: 300px; height: 257px;" /></div>
27 *
28 * Constraints:
29 *
30 * m == grid.length
31 * n == grid[i].length
32 * 1 <= m, n <= 50
33 * 0 <= grid[i][j] < 2500
34 *
35 *
36 * <div class="spoiler">
37 * <div>
38 *
39 *
40 * </div>
41 * </div>
42 *
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/
47// discuss: https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52 pub fn minimum_operations(grid: Vec<Vec<i32>>) -> i32 {
53 0
54 }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn test_3402() {
65 }
66}
67
Back
© 2025 bowen.ge All Rights Reserved.