2661. First Completely Painted Row or Column Medium
1/**
2 * [2661] First Completely Painted Row or Column
3 *
4 * You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n].
5 * Go through each index i in arr starting from index 0 and paint the cell in mat containing the integer arr[i].
6 * Return the smallest index i at which either a row or a column will be completely painted in mat.
7 *
8 * <strong class="example">Example 1:
9 * <img alt="" src="image explanation for example 1" /><img alt="image explanation for example 1" src="https://assets.leetcode.com/uploads/2023/01/18/grid1.jpg" style="width: 321px; height: 81px;" />
10 * Input: arr = [1,3,4,2], mat = [[1,4],[2,3]]
11 * Output: 2
12 * Explanation: The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2].
13 *
14 * <strong class="example">Example 2:
15 * <img alt="image explanation for example 2" src="https://assets.leetcode.com/uploads/2023/01/18/grid2.jpg" style="width: 601px; height: 121px;" />
16 * Input: arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]
17 * Output: 3
18 * Explanation: The second column becomes fully painted at arr[3].
19 *
20 *
21 * Constraints:
22 *
23 * m == mat.length
24 * n = mat[i].length
25 * arr.length == m * n
26 * 1 <= m, n <= 10^5
27 * 1 <= m * n <= 10^5
28 * 1 <= arr[i], mat[r][c] <= m * n
29 * All the integers of arr are unique.
30 * All the integers of mat are unique.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/first-completely-painted-row-or-column/
36// discuss: https://leetcode.com/problems/first-completely-painted-row-or-column/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn first_complete_index(arr: Vec<i32>, mat: Vec<Vec<i32>>) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_2661() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.