Question
Given an undirected graph on n nodes (edges [u, v]), determine if it is bipartite (2-colorable). If it is, return a two-element list [size_color_A, size_color_B] where, summed over connected components, color A gets the larger side of each component and color B the smaller (ties go to A). If the graph is NOT bipartite, return the single-element list [-1]. Isolated nodes form their own component of size 1.
bipartite_coloring(n: int, edges: list[list[int]]) → list[int][4,[[0,1],[1,2],[2,3],[3,0]]]out[2,2]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.