Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.