Class Solution
- java.lang.Object
-
- g2601_2700.s2661_first_completely_painted_row_or_column.Solution
-
public class Solution extends Object
2661 - First Completely Painted Row or Column.Medium
You are given a 0-indexed integer array
arr, and anm x ninteger matrixmat.arrandmatboth contain all the integers in the range[1, m * n].Go through each index
iinarrstarting from index0and paint the cell inmatcontaining the integerarr[i].Return the smallest index
iat which either a row or a column will be completely painted inmat.Example 1:


Input: arr = [1,3,4,2], mat = [[1,4],[2,3]]
Output: 2
Explanation: The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2].
Example 2:

Input: arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]
Output: 3
Explanation: The second column becomes fully painted at arr[3].
Constraints:
m == mat.lengthn = mat[i].lengtharr.length == m * n1 <= m, n <= 1051 <= m * n <= 1051 <= arr[i], mat[r][c] <= m * n- All the integers of
arrare unique. - All the integers of
matare unique.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfirstCompleteIndex(int[] arr, int[][] mat)
-