dsa · medium
Is Graph Bipartite
GreyOrangeGraphQueue
n nodes 0..n-1, undirected edges. Return whether the graph is bipartite.
Arguments
n— number of nodes, labeled0..n-1edges— the edge list
**Example**
`` Input: 4 [[0,1],[1,2],[2,3],[3,0]] Output: True ``
Constraints
1 <= n <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: 4 [[0,1],[1,2],[2,3],[3,0]] Expected: true
Example 2
Input: 3 [[0,1],[1,2],[2,0]] Expected: false