Simple || Clean || Java Solution
\njava []\nclass Solution {\n    public int firstCompleteIndex(int[] arr, int[][] mat) {\n        Map<Integer,Integer> map = new HashMap();\n        for(int i=0
\n``` java []\nclass Solution {\n    public int firstCompleteIndex(int[] arr, int[][] mat) {\n        Map<Integer,Integer> map = new HashMap();\n        for(int i=0; i<arr.length; i++) map.put(arr[i],i);\n        int min = arr.length;\n//      Row-wise checking\n        for(int i=0; i<mat.length; i++){\n            int max = 0;\n            for(int j=0; j<mat[0].length; j++){\n                max = Math.max(max, map.get(mat[i][j]));\n            }\n            min = Math.min(min,max);\n        }\n//      Col-wise checking\n        for(int i=0; i<mat[0].length; i++){\n            int max = 0;\n            for(int j=0; j<mat.length; j++){\n                max = Math.max(max, map.get(mat[j][i]));\n            }\n            min = Math.min(min,max);\n        }\n        return min;\n    }\n}\n```
['Java']