C++ 🔥 DRY RUN 🔥 single map
\n\n# Code\n\nclass Solution {\npublic:\n    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {\n\n    unordered_map<int,int>mp;\n    for(int 
\n![image.png](https://assets.leetcode.com/users/images/bdfd35b1-9880-466e-81ab-a997c64a08c7_1683038605.5310476.png)\n# Code\n```\nclass Solution {\npublic:\n    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {\n\n    unordered_map<int,int>mp;\n    for(int i = 0; i < arr.size(); i++) {\n        mp[arr[i]] = i;\n    }\n\n    int minIndex = INT_MAX , maxIndex = INT_MIN;\n    int rowSize = mat.size();\n    int colSize = mat[0].size();\n\n    for(int row = 0; row < rowSize; row++) {\n        maxIndex = INT_MIN;\n        for(int column = 0; column < colSize; column++) {\n            int indexVal = mp[mat[row][column]];\n            maxIndex = max(maxIndex , indexVal);\n        }\n        minIndex = min(minIndex , maxIndex);\n    }\n    \n    for(int column = 0; column < colSize; column++) {\n        maxIndex = INT_MIN;\n        for(int row = 0; row < rowSize; row++) {\n            int indexVal2 = mp[mat[row][column]];\n            maxIndex = max(maxIndex , indexVal2);\n        }\n        minIndex = min(minIndex , maxIndex);\n    }\n    return minIndex;   \n}\n};    \n\n```
['C++']