✅ 🔥 Faster | Greedy | Beginner friendly ✅ 🔥
IntuitionTwo key thing to look upon is knowing the position of each element and finding whether a particular row or column is paintedApproach
Achieve the first
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Two key thing to look upon is knowing the position of each element and finding whether a particular row or column is painted 

# Approach
<!-- Describe your approach to solving the problem. -->
1. Achieve the first step by storing the index value of each item in an array called indexArray, where 1 -> [x][y], 2 -> [x][y], and so on.
2. You can determine if a row or column is painted by keeping track of a rowArray and a columnArray. Painting any cell in a row or column increases its corresponding value, and once it reaches n (for rows) or m (for columns), the value is returned.

# Complexity
- Time complexity: O(m x n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O (m x n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def firstCompleteIndex(self, arr: List[int], mat: List[List[int]]) -> int:
        m = len(mat)
        n = len(mat[0])
        ln = len(arr)
        index = [[0, 0] for _ in range(0, ln+1)]
        row = [0] * m
        col = [0] * n
        for i in range (0, m):
            for j in range (0, n):
                val = mat[i][j]
                index[val][0] = i
                index[val][1] = j
        res=0
        for i in range (0, ln):
            val = arr[i]
            row[index[val][0]]+=1
            col[index[val][1]]+=1
            res+=1
            if row[index[val][0]]==n or col[index[val][1]]==m:
                return res-1
        return res-1
```
['Greedy', 'Python3']