 || ✅#DAY_64th_Of_Daily_Coding✅||
JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏Code
# JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

# Code
```cpp []
class Solution {
public:
    class DSU {
    public:
        vector<int> parent, rank;
        
        DSU(int size) {
            parent.resize(size);
            rank.resize(size, 1);
            for (int i = 0; i < size; i++) {
                parent[i] = i;
            }
        }

        int findParent(int node) {
            if (parent[node] != node) {
                parent[node] = findParent(parent[node]);
            }
            return parent[node];
        }

        void mergeSets(int node1, int node2) {
            int root1 = findParent(node1);
            int root2 = findParent(node2);
            
            if (root1 != root2) {
                if (rank[root1] > rank[root2]) {
                    parent[root2] = root1;
                } else if (rank[root1] < rank[root2]) {
                    parent[root1] = root2;
                } else {
                    parent[root2] = root1;
                    rank[root1]++;
                }
            }
        }
    };

    int numberOfComponents(vector<vector<int>>& properties, int k) {
        int n = properties.size();
        DSU dsu(n);

        // Precompute bitmask for each set
        vector<bitset<101>> bitmasks(n);
        for (int i = 0; i < n; i++) {
            for (int num : properties[i]) {
                bitmasks[i].set(num);  // Set the bit at position `num`
            }
        }

        // Compare each pair of sets and merge if they share at least `k` common elements
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                // Count common elements using bitwise AND
                int common = (bitmasks[i] & bitmasks[j]).count();
                if (common >= k) {
                    dsu.mergeSets(i, j);
                }
            }
        }

        // Count the number of unique components
        unordered_set<int> uniqueComponents;
        for (int i = 0; i < n; i++) {
            uniqueComponents.insert(dsu.findParent(i));
        }

        return uniqueComponents.size();
    }
};
```
['C++', 'Java']