Loop through the input edges. For every edge [u, v]:
Check find(u) and find(v).
If they are the same, this edge creates a cycle. Return it.
Otherwise, union(u, v) and continue.
The problem guarantees exactly one redundant edge, so you will always find it. Return the last edge that would form a cycle. Time: . Space: for the parent and rank arrays.