Store Row and Col
Go through the matrix and, for each number, remember the row and col using mn.\n\nThen, count how many elements are painted in each row and column using mc and 
Go through the matrix and, for each number, remember the row and col using `mn`.\n\nThen, count how many elements are painted in each row and column using `mc` and `nc`.\n\n**C++**\n```cpp\nint firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {\n    int m = mat.size(), n = mat[0].size(), k = 0;\n    vector<int> mc(m), nc(n);\n    vector<array<int, 2>> mn(m * n + 1);\n    for (int i = 0; i < m; ++i)\n        for (int j = 0; j < n; ++j)\n            mn[mat[i][j]] = {i, j};\n    for (; ; ++k)\n        if (++mc[mn[arr[k]][0]] == n || ++nc[mn[arr[k]][1]] == m)\n            break;\n    return k;\n}\n```
['C']