Class Solution
java.lang.Object
g2601_2700.s2661_first_completely_painted_row_or_column.Solution
2661 - First Completely Painted Row or Column.<p>Medium</p>
<p>You are given a <strong>0-indexed</strong> integer array <code>arr</code>, and an <code>m x n</code> integer <strong>matrix</strong> <code>mat</code>. <code>arr</code> and <code>mat</code> both contain <strong>all</strong> the integers in the range <code>[1, m * n]</code>.</p>
<p>Go through each index <code>i</code> in <code>arr</code> starting from index <code>0</code> and paint the cell in <code>mat</code> containing the integer <code>arr[i]</code>.</p>
<p>Return <em>the smallest index</em> <code>i</code> <em>at which either a row or a column will be completely painted in</em> <code>mat</code>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2023/01/18/grid1.jpg" alt="image explanation for example 1" /></p>
<p><strong>Input:</strong> arr = [1,3,4,2], mat = [[1,4],[2,3]]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2].</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2023/01/18/grid2.jpg" alt="image explanation for example 2" /></p>
<p><strong>Input:</strong> arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> The second column becomes fully painted at arr[3].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == mat.length</code></li>
<li><code>n = mat[i].length</code></li>
<li><code>arr.length == m * n</code></li>
<li><code>1 <= m, n <= 10<sup>5</sup></code></li>
<li><code>1 <= m * n <= 10<sup>5</sup></code></li>
<li><code>1 <= arr[i], mat[r][c] <= m * n</code></li>
<li>All the integers of <code>arr</code> are <strong>unique</strong>.</li>
<li>All the integers of <code>mat</code> are <strong>unique</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
firstCompleteIndex
public int firstCompleteIndex(int[] arr, int[][] mat)
-