Very intuitive solution || Double Hashing || Must Learn || Please Upvote
IntuitionMaintain the live count of elements in rows and columns. At index i in arr remove the element from the live counts.If the count of row or column become
# Intuition
Maintain the live count of elements in rows and columns. At index i in arr remove the element from the live counts.If the count of row or column becomes 0 return the index i.

# Approach
Maintain a row, column hashmap the sotres count of numbers not yet seen in arr. If any row or column turns 0 return the current index of arr.

# Complexity
- Time complexity:
$$O(m.n)$$ --> The size of array is m.n.

- Space complexity:
$$O(n+m)$$ --> Creating the row, column hashmaps.

# Code
```python3 []
class Solution:
    def firstCompleteIndex(self, arr: List[int], mat: List[List[int]]) -> int:
        r,c = len(mat),len(mat[0])
        rows = {x:c for x in range(r)}
        cols = {x:r for x in range(c)}
        m = defaultdict()
        for i in range(r):
            for j in range(c):
                m[mat[i][j]] = (i,j)
        for i in range(len(arr)):
            row,col = m[arr[i]]
            rows[row] -= 1
            cols[col] -= 1
            if rows[row] == 0 or cols[col] == 0:
                return i
```
['Array', 'Hash Table', 'Matrix', 'Python', 'Python3']