Solution 1 BFS + 染色法

0 represents unvisited nodes, 1 and 2 represent two colors

把相邻的节点染成不同颜色,如果相邻节点颜色相同,则返回 false

Last updated