vector<int>findOrder(intn,vector<vector<int>>&adj){vector<int>indegree(n,0);for(inti=0;i<n;i++){for(intj:adj[i]){indegree[j]++;}}queue<int>q;for(inti=0;i<n;i++){if(indegree[i]==0)q.push(i);}vector<int>ans;while(!q.empty()){intnode=q.front();q.pop();ans.push_back(node);for(intnbr:adj[node]){if(--indegree[nbr]==0){q.push(nbr);}}}return(ans.size()==n)?ans:vector<int>();//check if there's a cycle}