Divide Nodes Into the Maximum Number of Groups | Leetcode 2493