Different from other solutions maybe.. ?
I did not understand the other solutions so I don't know if this is the same thingIntuitionWe first map the elements in the of arr with their respective indexAf
I did not understand the other solutions so I don't know if this is the same thing 

# Intuition

We first map the elements in the of arr with their respective index

After that we traverse through the matrix row-wise and column-wise
We keep track of which element is coming in the last in the matrix with the help of variable 'temp' 
The answer would the element which is coming in the least possible index so we take the minimum there
Doing same for the columns we get the asnwer

# Code
```cpp []
class Solution {
public:
    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {
        unordered_map<int, int> mp;
        for(int i = 0; i < arr.size(); i++) mp[arr[i]] = i;
        int n = mat.size(), m = mat[0].size(), ans = INT_MAX;
        for(int i = 0; i < n; i++){
            int temp = INT_MIN;
            for(int j = 0; j < m; j++){
                temp = max(temp, mp[mat[i][j]]);
            }
            ans = min(temp, ans);
        }
        for(int i = 0; i < m; i++){
            int temp = INT_MIN;
            for(int j = 0; j < n; j++){
                temp = max(temp, mp[mat[j][i]]);
            }
            ans = min(temp, ans);
        }
        return ans;
    }
};
```
['C++']