← ALL NOTES
Depth-First Search

2493. Divide Nodes Into the Maximum Number of Groups

Given an undirected graph of n nodes, partition the nodes into groups 1, 2, 3, … so that for every edge [a, b], the group numbers of a and b differ by exactly 1. Maximize the number of groups; if no…

Loading…