Reference: LeetCode
Difficulty:

## Problem

Check if a graph is bipartite? The graph could be disconnected.

Note: There are no self edges or parallel edges.

Example:

## Analysis

### DFS or BFS

Note: Graph may be disconnected, so we should do DFS on each unvisited node.

Time: $O(V + E)$
Space: $O(V)$

Comment
Junhao Wang
Hi, I was a master student at USC studying Computer Science.