97. Is the Graph Bipartite?
MediumGraphs
An undirected graph is given as an adjacency list: graph[i] lists the neighbours of vertex i. Return true if the vertices can be split into two groups so that every edge joins vertices from different groups.
The graph may be disconnected and has no self-loops.
Example 1
Input: graph = [[1,3],[0,2],[1,3],[0,2]] Output: true
Example 2
Input: graph = [[1,2,3],[0,2],[0,1,3],[0,2]] Output: false
Constraints
0 ≤ n ≤ 100