You are given m groups, described by the array group, where:
group[i] represents the group of the
If group[i]
You’re also given a list, beforeItems, where beforeItems[i] contains all items that must precede item
Your goal is to arrange all
Dependency order: Every item must appear after all the items listed in beforeItems[i].
Group continuity: All items that belong to the same group must appear next to each other in the final order.
If there are multiple valid orderings, return any of them. If there’s no possible ordering, return an empty list.
Constraints:
You are given m groups, described by the array group, where:
group[i] represents the group of the
If group[i]
You’re also given a list, beforeItems, where beforeItems[i] contains all items that must precede item
Your goal is to arrange all
Dependency order: Every item must appear after all the items listed in beforeItems[i].
Group continuity: All items that belong to the same group must appear next to each other in the final order.
If there are multiple valid orderings, return any of them. If there’s no possible ordering, return an empty list.
Constraints: