public int[] bfs(int[] incoming, int numCourses) {
        int[] ans = new int[numCourses];
        int visited = 0;
        Queue<Integer> toVisit = new LinkedList<Integer>();
        for (int i = 0; i < numCourses; ++i) {
            if (incoming[i] == 0) {
                toVisit.offer(i);
            }
        }
        while (!toVisit.isEmpty()) {
            int from = toVisit.poll();
            ans[visited++] = from;
            for (int to : adjList.get(from)) {
                incoming[to]--;
                if (incoming[to] == 0)
                    toVisit.offer(to);
            }
        }
        if (visited == numCourses)
            return ans;
        return new int[0];
    }