Easiest solution available in solutions. 100% faster (0ms) using union find
IntuitionIf while iterating the edges vector, we check the node is connected or not we can easily find the solution, here comes union find (dsu). just get the u
# Intuition
If while iterating the edges vector, we check the node is connected or not we can easily find the solution, here comes union find (dsu). just get the union finds template from gfg.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
After getting the union find code. just iterate through the edges and check if it is connected before than this edge will lead to form a closed curve hence that edge will be the answer.
<!-- Describe your approach to solving the problem. -->

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

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

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

    int find(int i) {
        if (parent[i] != i) {
            parent[i] = find(parent[i]);
        }
        return parent[i];
    }

    void unite(int i, int j) {
        int rootI = find(i);
        int rootJ = find(j);

        if (rootI != rootJ) {
            
            if (rank[rootI] > rank[rootJ]) {
                parent[rootJ] = rootI;
            } else if (rank[rootI] < rank[rootJ]) {
                parent[rootI] = rootJ;
            } else {
                parent[rootJ] = rootI;
                rank[rootI]++;
            }
        }
    }
};
class Solution {
public:
    vector<int> findRedundantConnection(vector<vector<int>>& edges) {
        int n = edges.size();
        UnionFind uf(n+1);
        for(auto i : edges){
            int p1 = uf.find(i[0]);
            int p2 = uf.find(i[1]);
            if(p1==p2){
                return i;
            }else{
                uf.unite(i[0], i[1]);
            }
        }
        
        return {};
    }
};
```
['Union Find', 'Graph', 'C++']