C# Solution | Disjoint Set Union 
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
```csharp []
public class Solution {
    public int[] MinimumCost(int n, int[][] edges, int[][] query) {
        int[][] parent = new int[n][];
        int[] res = new int[query.Length];

        for(int i=0; i<n; i++){
            parent[i] = new int[2]{ i, int.MaxValue };
        }

        foreach(var edge in edges){
            var p1 = GetParent(parent, edge[0]);
            var p2 = GetParent(parent, edge[1]);
            parent[p2[0]][0] = p1[0];
            p1[1] = (p1[1]&p2[1]&edge[2]);
        }

        for(int i=0; i<query.Length; i++){
            var p1 = GetParent(parent, query[i][0]);
            var p2 = GetParent(parent, query[i][1]);

            if(p1[0] == p2[0]){
                res[i] = p1[1];
            }
            else{
                res[i] = -1;
            }
        }

        return res;
    }   

    private int[] GetParent(int[][] parent, int node){
        if(parent[node][0] == node){
            return parent[node];
        } 

        var p = GetParent(parent, parent[node][0]);
        parent[node][0] = p[0];
        return p;
    }
}
```
['Array', 'Bit Manipulation', 'Union Find', 'Graph', 'C#']