Search
⌘K

Leetcode 1203. Sort Items by Groups Respecting Dependencies

Order n items subject to precedence constraints while ensuring all items of the same group appear consecutively. The core challenge is to perform topological sorting (with cycle detection) on both item and group dependency graphs—after assigning unique groups to ungrouped items—to produce a valid grouped ordering or return empty if impossible.


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.