Veeva·Software Engineer·Technical Phone Screen
- You're given a directed graph as an adjacency map where each key points to a list of tasks that depend on it. Implement a function that returns a valid execution order of all tasks reachable from a given starting node, with prerequisites always appearing first. Break ties alphabetically, detect any cycles, and explain the time and space complexity of your solution.
“The core of it is just topological sort with DFS and a visited set for cycle detection, but the alphabetical tie-breaking tripped me up.”