Java Concise BitSet 98% | Problem Explanation
Let\'s say we have an interger of 500 bits, then we can set the bit for each person for the language they speak, so if person A speaks langage 1 and 4 out of 4 
Let\'s say we have an interger of 500 bits, then we can set the bit for each person for the language they speak, so if person A speaks langage 1 and 4 out of 4 language, it\'d be represented as `0b1001`. We can then just `&`  it with another person\'s number to find out if they share a common language.\n\nThe issue here is that we don\'t have a 500-bit integer, but we do have a bitset class which can represent that and has all the bitwise operation built-in, so let\'s use that.\n\n**THIS QUESTION IS VERY CONFUSING**. I spent 3 hrs just to understand what was being asked. You are **ONLY** allowed to teach `1` language to EVERYBODY. \nTake this test case for example:\n```\n4\n[[1],[2],[3],[4]]\n[[1,2],[3,4]]\n```\nOne may intuitively think that the answer should be 2 because we can teach person 1 the 2nd language and person 3 the 4th language; However that\'s against the rule because we are only allowed to teach **exactly** 1 language. Because we are only allowed to teach 1 language, we should teach the language that are most common so as to reduce the number of user that needs to be taught. \n\n**Java (98% Speed):**\n\n```Java\nclass Solution {\n    public int minimumTeachings(int n, int[][] L, int[][] F) {\n        BitSet[] bit = new BitSet[L.length];\n        Arrays.setAll(bit, o -> new BitSet(n + 1));\n        for (int i = 0; i < L.length; i++){\n            for (int l : L[i]){\n                bit[i].set(l);\n            }\n        }\n        Set<Integer> teach = new HashSet<>();\n        for (int[] f : F){\n            BitSet t = (BitSet)bit[f[0] - 1].clone();\n            t.and(bit[f[1] - 1]);\n            if (t.isEmpty()){\n                teach.add(f[0] - 1);\n                teach.add(f[1] - 1);\n            }\n        }\n        int[] count = new int[n + 1];\n        for (int person : teach){\n            for (int l : L[person]){\n                count[l]++;\n            }\n        }\n\n        return teach.size() - Arrays.stream(count).max().getAsInt();\n    }\n}\n```
['Java']