dsa · medium

Is Graph Bipartite

GreyOrangeGraphQueue

n nodes 0..n-1, undirected edges. Return whether the graph is bipartite.

Arguments

**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

Open in the Dojo editor