Easy to understand code || Simple Mapping
\nclass Solution {\npublic:\n    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) \n    {\n        int m = mat.size(), n = mat[0].size();\n   
```\nclass Solution {\npublic:\n    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) \n    {\n        int m = mat.size(), n = mat[0].size();\n        vector<int>rowFill(m, 0); //rowFill[i] => how much columns are filled in row = i\n        vector<int>colFill(n, 0); //colFill[i] => how much rows are filled in col = i\n        //=========================================================================\n        vector<int>rowIdxMap((m * n) + 1); //mapping row index and col index for each value\n        vector<int>colIdxMap((m * n) + 1);\n        for (int i = 0; i < m; i++)\n        {\n            for (int j = 0; j < n; j++)\n            {\n                int val = mat[i][j];\n                rowIdxMap[val] = i;\n                colIdxMap[val] = j;\n            }\n        }\n        //================================================================================\n        for (int i = 0; i < arr.size(); i++)\n        {\n            int val = arr[i];\n            int rowIdx = rowIdxMap[val];\n            int colIdx = colIdxMap[val];\n            \n            rowFill[rowIdx]++;\n            colFill[colIdx]++;\n            if (rowFill[rowIdx] == n || colFill[colIdx] == m) return i;\n        }\n        //===============================================================================\n        return -1;\n        \n    }\n};\n```
['Hash Table', 'C', 'C++']