🚀🚀 Easy way 🔥3493. Properties Graph 👇
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class DSU {
    int p[];
    int r[];

    DSU(int n) {
        p = new int[n];
        r = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = i;
    }

    public int find(int x) {
        if (x != p[x])
            p[x] = find(p[x]);
        return p[x];
    }

    public void union(int x, int y) {
        int a = find(x);
        int b = find(y);
        if (a == b)
            return;
        if (r[a] > r[b])
            p[b] = a;
        else if (r[a] < r[b])
            p[a] = b;
        else {
            p[b] = a;
            r[a]++;
        }
    }
}

class Solution {
    int intersect_check(Set<Integer> a, Set<Integer> b) {
        int c = 0;
        for (int num : a) {
            if (b.contains(num))
                c++;
        }
        return c;
    }

    public int numberOfComponents(int[][] properties, int k) {
        int n = properties.length;
        DSU dsu = new DSU(n);

        List<Set<Integer>> List = new ArrayList<>();
        for (int[] p : properties) {
            Set<Integer> s = new HashSet<>();
            for (int num : p)
                s.add(num);
            List.add(s);
        }

        for (int x = 0; x < n; x++) {
            for (int y = x + 1; y < n; y++) {
                if (intersect_check(List.get(x), List.get(y)) >= k) {
                    dsu.union(x, y);
                }
            }
        }
        Set<Integer> ans = new HashSet<>();
        for (int i = 0; i < n; i++) {
            ans.add(dsu.find(i));
        }
        return ans.size();
    }
}

```
['Java']