Detect Cycle in Undirected Graph BFS

Given an undirected graph with n vertices and edges, detect if the graph contains a cycle. Return true if cycle exists, false otherwise.

Examples
Input: [5,[[0,1],[1,2],[2,3],[3,4]]]
Output: false
Hints

Detect Cycle in Undirected Graph BFS

Given an undirected graph with n vertices and edges, detect if the graph contains a cycle. Return true if cycle exists, false otherwise.