There is an undirected graph with n nodes, numbered between 0 and n-1. You are provided with a 2D array graph, where graph[u] is an array of nodes adjacent to node u. The graph is undirected, has no self-edges, and no parallel edges. It may not be connected. A graph is bipartite if its nodes can be divided into two independent sets A and B such that every edge connects one node in set A and one node in set B. Return true if and only if the graph is bipartite.
Click Run to execute sample tests.