100% BEAT Java Easy ✅
Time complexity: O(NM\nSpace complexity: O(1)\n- We simply count freq of each elements.\n- And each array is distinct elements so if elements freq is equal to l
***Time complexity***: O(N*M\n***Space complexity***: O(1)\n- We simply count `freq` of each elements.\n- And each array is `distinct` elements so if elements freq is equal to len it means it ocuur in all array. And each array is `distinct` elements.\n- And we make freq array `1001` size because `1 <= sum(nums[i].length) <= 1000`.\n- and we don\'t have -1 every time so that\'s why i make `1001` size instead of `1000` because index start from `0`.\n# Code\n```\nclass Solution {\n    public List<Integer> intersection(int[][] nums) {\n        int freq[] = new int[1001];\n        int len = nums.length;\n        \n        for(int i = 0; i < nums.length; i++){\n            for(int j = 0; j < nums[i].length; j++){\n                freq[nums[i][j]]++;\n            }\n        }\n\n        List<Integer> list = new ArrayList<>();\n\n        for(int i = 1; i < 1001; i++){\n            if(freq[i] == len) list.add(i);\n        }\n        return list;\n    }\n}\n```\n\n\n![upvote.jpeg](https://assets.leetcode.com/users/images/b0f2564b-6796-4995-a702-c01f4536ba25_1700118733.5773835.jpeg)\n**HAPPY CODING !**\n\n
['Java']