Topological sorting

Give one valid order.

Examples

Worked example

Input
A → C and B → C
Expected output
A, B, C

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Both A and B are available at the start. C becomes available after both predecessors are removed.

Back to the lesson