Modules import each other. Input: a JSON object mapping module → array of modules it imports. A module loads only after its imports. Print a valid load order, choosing alphabetically among ready modules, comma-separated.
Input: one JSON object (the graph is acyclic).
Output: load order like a,b,c.
Your program reads from stdin and prints to stdout.
Example 1
Input: {"app":["utils","api"],"api":["utils"],"utils":[]}
Output: utils,api,app
Hints
Modules import each other. Input: a JSON object mapping module → array of modules it imports. A module loads only after its imports. Print a valid load order, choosing alphabetically among ready modules, comma-separated.
Input: one JSON object (the graph is acyclic).
Output: load order like a,b,c.
Your program reads from stdin and prints to stdout.
Example 1
Input: {"app":["utils","api"],"api":["utils"],"utils":[]}
Output: utils,api,app
Hints