Using HashMap by Storing the Index values || Beats 90% of Java Code
IntuitionApproachComplexity
Time complexity:O(m*n)

Space complexity: O(m*n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- 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)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int firstCompleteIndex(int[] arr, int[][] mat) {
        int m=mat.length; //no of rows
        int n=mat[0].length;
        int[] rowCount=new int[m]; //to check whether any row
        int[] colCount= new int[n];// col is equal to m|n.

        HashMap<Integer,int[]>lookupMap =new HashMap<>(); // to store the index of value

        for(int i=0;i<m;i++){ //storing the values in lookupMap along with index
            for(int j=0;j<n;j++){
                lookupMap.put(mat[i][j],new int[]{i,j});
            }
        }

        int[]temp;
        int row,col;
        for(int i=0;i<arr.length;i++){
            temp=lookupMap.get(arr[i]);
            row=temp[0];
            col=temp[1];

            rowCount[row]++;
            colCount[col]++;

            if(rowCount[row]==n || colCount[col]==m) // a whole row will be painted when it's all col is visited
                return i;
        }

        return -1;

    }
}
```
['Hash Table', 'Java']