Problem 1203 · Hard

Sort Items by Groups Respecting Dependencies

Keep each group together and every dependency first by topologically sorting groups, then items inside them.

Open the interactive visualisation