Is Graph Bipartite?

Given an undirected graph represented as an adjacency list graph, where graph[u] lists the nodes adjacent to node u, determine whether the graph is bipartite. A graph is bipartite when its nodes can be split into two sets A and B such that every edge joins a node in A to a node in B. Equivalently, the nodes can be colored with two colors so that no edge connects two nodes of the same color. Return true if the graph is bipartite, and false otherwise. The graph may be disconnected, so every component must be checked independently.

Examples
Input: [[1,3],[0,2],[1,3],[0,2]]
Output: true
Hints

Is Graph Bipartite?

Given an undirected graph represented as an adjacency list `graph`, where `graph[u]` lists the nodes adjacent to node `u`, determine whether the graph is bipartite. A graph is bipartite when its nodes can be split into two sets `A` and `B` such that every edge joins a node in `A` to a node in `B`. Equivalently, the nodes can be colored with two colors so that no edge connects two nodes of the same color. Return `true` if the graph is bipartite, and `false` otherwise. The graph may be disconnected, so every component must be checked independently.