C++ BFS using Topological sort (Kahn's algorithm)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> getAncestors(int n, vector<vector<int>>& edges) {\n        vector<vector<int>> adj(n);\n        vector<vector<int>> ans(n);\n        vector<unordered_map<int,bool>> done(n);\n        vector<int> indegree(n,0);\n        for(auto i: edges)\n        {\n            adj[i[0]].push_back(i[1]);\n            indegree[i[1]]++;\n        }\n        queue<int> q;\n        for(int i=0;i<n;i++)\n        {\n            if(indegree[i]==0) q.push(i);\n        }\n        while(!q.empty())\n        {\n            int t=q.front();\n            q.pop();\n            for(auto i:adj[t])\n            {\n                for(auto j:ans[t]) {\n                    if(done[i][j]==0){\n                        ans[i].push_back(j);\n                        done[i][j]=1;\n                    }\n                }\n                if(done[i][t]==0){\n                        ans[i].push_back(t);\n                        done[i][t]=1;\n                    }\n                indegree[i]--;\n                if(indegree[i]==0) q.push(i);\n            }\n        }\n        for(auto &i:ans)\n        {\n            sort(i.begin(),i.end());\n        }\n        return ans;\n    }\n};\n```
['Topological Sort', 'C++']