The input is already an adjacency list. graph[i] gives you all neighbors of node i directly. No need to build the graph yourself. For example, if graph = [[1,3],[0,2],[1,3],[0,2]], then: - Node 0 connects to nodes 1 and 3 - Node 1 connects to nodes 0 and 2 - Node 2 connects to nodes 1 and 3 - Node 3 connects to nodes 0 and 2 This is a 4-cycle: 0-1-2-3-0.
Since 4 is even, this graph should be bipartite.