Bipartite graph check: Given an undirected graph, return whether every connected component can be colored with two colors so adjacent nodes differ.
Input: A JSON object { "n": number, "edges": [number,number][] }.
Output: A JSON boolean.
Constraints:
- 0 <= n <= 100000
- Nodes are numbered from 0 to n-1
- The graph may be disconnected
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: MEDIUM. Variant: 2. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked medium difficulty.
The signed-in workspace provides the tools required by the round, such as recording, code execution, diagrams, structured notes, o