3 approach JAVA sol
Using array as HashMap :\n\n public List<Integer> intersection(int[][] a) {\n        List<Integer> ans =new ArrayList<>();\n        int dp[]=new int[1001];\n   
Using array as HashMap :\n```\n public List<Integer> intersection(int[][] a) {\n        List<Integer> ans =new ArrayList<>();\n        int dp[]=new int[1001];\n        \n        for(int i=0;i<a.length;i++)\n        {\n            for(int x: a[i])\n            {\n                dp[x]++;\n            }\n        }\n        \n        for(int i=1;i<=1000;i++) if(dp[i]==a.length)ans.add(i);\n        \n        return ans;\n    }\n```\n\nSimple Hashmap soln :\n```\npublic List<Integer> intersection(int[][] a) {\n        List<Integer> ans =new ArrayList<>();\n        HashMap<Integer,Integer> hm =new HashMap<>();\n        \n        for(int i=0;i<a.length;i++)\n        {\n            for(int x : a[i])\n            {\n                if(!hm.containsKey(x)) hm.put(x,0);\n                  \n                hm.put(x,hm.get(x)+1);\n            }\n        }\n        \n        for(int key : hm.keySet())\n        {\n            if(hm.get(key)==a.length)ans.add(key);\n        }\n        \n        Collections.sort(ans);\n        return ans;\n    }\n```\nHashSet soln : \n\n```\n    public List<Integer> intersection(int[][] a) {\n        List<Integer> ans =new ArrayList<>();\n        HashSet<Integer> cur =new HashSet<>();\n        for(int i=0;i<a[0].length;i++) cur.add(a[0][i]);\n        \n        for(int i=1;i<a.length;i++)\n        {  HashSet<Integer> newcur =new HashSet<>(); \n           for(int x : a[i])\n           {\n               if(cur.contains(x)) newcur.add(x);\n           }\n           cur=newcur;\n        }\n        \n        for(int x : cur) ans.add(x);\n        \n        Collections.sort(ans);\n        \n        return ans;\n    }\n```\n
[]