Is the Graph Bipartite?
Question (LC.785)
Given a social network, divide people into two groups in which no one knows any other member in that group.
Example
I: [[1,3], [0,2], [1,3], [0,2]]
O: true
I: [[1,2,3], [0,2], [0,1,3], [0,2]]
O: false
Analysis
We can model the social network as an undirected graph. Then, we can use either DFS or BFS to determine the graph is bipartite or not.
Last updated