Is Graph Bipartite?
Medium · Graphs · about 20 minutes
Asked at Meta, Google, LinkedIn.
An undirected graph with n nodes is given as an adjacency list graph, where graph[u] lists the neighbors of u (it may be disconnected). Return true if the nodes can be split into two groups such that every edge connects nodes from different groups.