Pergunta de entrevista da empresa Cadence Design Systems

How to detect cycles in a undirected graph using the union-find data structure?