3033. Modify the Matrix Easy

@problem@discussion
#Array#Matrix



1/**
2 * [3033] Modify the Matrix
3 *
4 * Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer. Make answer equal to matrix, then replace each element with the value -1 with the maximum element in its respective column.
5 * Return the matrix answer.
6 *  
7 * <strong class="example">Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2023/12/24/matrix1.png" style="width: 491px; height: 161px;" />
9 * Input: matrix = [[1,2,-1],[4,-1,6],[7,8,9]]
10 * Output: [[1,2,9],[4,8,6],[7,8,9]]
11 * Explanation: The diagram above shows the elements that are changed (in blue).
12 * - We replace the value in the cell [1][1] with the maximum value in the column 1, that is 8.
13 * - We replace the value in the cell [0][2] with the maximum value in the column 2, that is 9.
14 * 
15 * <strong class="example">Example 2:
16 * <img alt="" src="https://assets.leetcode.com/uploads/2023/12/24/matrix2.png" style="width: 411px; height: 111px;" />
17 * Input: matrix = [[3,-1],[5,2]]
18 * Output: [[3,2],[5,2]]
19 * Explanation: The diagram above shows the elements that are changed (in blue).
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	m == matrix.length
25 * 	n == matrix[i].length
26 * 	2 <= m, n <= 50
27 * 	-1 <= matrix[i][j] <= 100
28 * 	The input is generated such that each column contains at least one non-negative integer.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/modify-the-matrix/
34// discuss: https://leetcode.com/problems/modify-the-matrix/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn modified_matrix(matrix: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
40        vec![]
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_3033() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.