Back to course home
0% completed
Is Graph Bipartite? (medium)
Problem Statement
Given a 2D array graph[][]
, representing the undirected graph
, where graph[u]
is an array of nodes that are connected with node u
.
Determine whether a given undirected graph is a bipartite graph
.
The graph is a bipartite graph
, if we can split
the set of nodes into two distinct subsets
such that no two nodes within the same subset are adjacent
(i.e., no edge exists between any two nodes within a single subset).
Examples
- Example 1:
- Input: graph =
[[1,3], [0,2], [1,3], [0,2]]
- Input: graph =
- Expected Output:
true
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Problem Statement
Examples
Try it yourself