class Solution { public: vector<int> findSmallestSetOfVertices(int n, vector<vector<int>>& edges) { vector<bool> v(n,false); for(int i=0;i<edges.size();i++) { v[edges[i][1]]=true; } vector<int> ans; for(int i=0;i<n;i++) { if(!v[i]) ans.push_back(i); } return ans; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter