Search
⌘K

Leetcode 2493. Divide Nodes Into the Maximum Number of Groups

Assign each node an integer group 1..m so every edge joins nodes whose group indices differ by exactly 1; return the maximum possible m or -1 if no such labeling exists. Core challenge: detect impossibility (odd cycles) and compute the maximum feasible layering (longest valid BFS-like level assignment) across the graph/components.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.