C++ solution!!! Easy approach
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {
        int m=mat.size();
        int n=mat[0].size();
        vector<int>r(m,0);
        vector<int>c(n,0);
        unordered_map<int,int>m1,m2;
        
       for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
          m1[mat[i][j]]=i;
          m2[mat[i][j]]=j;
        }
       } 
       for(int i=0;i<arr.size();i++){
        r[m1[arr[i]]]++;
        c[m2[arr[i]]]++;
        
        if(r[m1[arr[i]]]==n||c[m2[arr[i]]]==m)return i;
       }
       return -1;
    }
};
```
['C++']