10 line Java solution, Union Find.
\nclass Solution {\n    public int[] findRedundantConnection(int[][] edges) {\n        int[] parent = new int[2001];\n        for (int i = 0; i < parent.length;
```\nclass Solution {\n    public int[] findRedundantConnection(int[][] edges) {\n        int[] parent = new int[2001];\n        for (int i = 0; i < parent.length; i++) parent[i] = i;\n        \n        for (int[] edge: edges){\n            int f = edge[0], t = edge[1];\n            if (find(parent, f) == find(parent, t)) return edge;\n            else parent[find(parent, f)] = find(parent, t);\n        }\n        \n        return new int[2];\n    }\n    \n    private int find(int[] parent, int f) {\n        if (f != parent[f]) {\n          parent[f] = find(parent, parent[f]);  \n        }\n        return parent[f];\n    }\n}\n```
[]