Given an undirected graph with N vertices and M edges, determine whether the graph contains a cycle.
Asked in the Technical round 1 stage. Candidate started with a hash map approach then optimised.
n: number of vertices labeled 0 to n - 1edges: list of undirected edges, where each edge is [u, v]Return True if the graph contains at least one cycle, otherwise return False.
def has_cycle(n, edges):