Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int findLongestPath(vector<int> topSortOrder, vector<vector<int>>& g) {
- int n = topSortOrder.size();
- vector<int> dist(n,0);
- int ans = 0;
- for(int i=0;i<n;i++) {
- int node = topSortOrder[i];
- for(auto& ch: g[node]) {
- dist[ch] = max(dist[ch], 1 + dist[node]);
- ans = max(ans,dist[ch]);
- }
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement