Easy Beginner Friendly C++ Sol
Please Upvote!!🥺🙏❤️Complexity
Time complexity:O(M∗N)

Space complexity:O((M∗N)+(M+N))=O(M∗N)
Code
# Please Upvote!!🥺🙏❤️
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {
        int rows = mat.size();
        int cols = mat[0].size();

        unordered_map<int, pair<int, int>> ump;  // val, row, col
        vector<int> row_cnt(rows);
        vector<int> col_cnt(cols);
        
        for(int r=0; r<rows; r++){
            for(int c=0; c<cols; c++){
                int val = mat[r][c];
                ump[val] = {r, c};
            }
        }

        for(int i=0; i<arr.size(); i++){
            int num = arr[i];
            auto [r, c] = ump[num];
            
            row_cnt[r]++;
            col_cnt[c]++;

            if(row_cnt[r] == cols || col_cnt[c] == rows){
                return i;
            }
        }

        return -1;
    }
};
```
['Array', 'Hash Table', 'Math', 'Brainteaser', 'Matrix', 'Simulation', 'C++']