diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/min_num_vertices_node.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/min_num_vertices_node.cpp')
-rw-r--r-- | other/min_num_vertices_node.cpp | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/other/min_num_vertices_node.cpp b/other/min_num_vertices_node.cpp deleted file mode 100644 index 2d53fed..0000000 --- a/other/min_num_vertices_node.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// 1557. Minimum Number of Vertices to Reach All Nodes -#include "leetcode.h" - -/* - * given a directed acyclic graph, with 'n' vertices numbered from 0 to 'n - 1', - * and an array 'edges', where 'edges[i] = [fromi, toi]' representes a directed - * edge from node 'fromi' to node 'toi'. find the smallest set of vertices from - * which all nodes in the graph are reachale. it's guaranteed that a unique - * solution exists. notice you cano return the vertices in any order. - */ - -class Solution { -public: - vector<int> findSmallestSetOfVertices(int n, vvd & edges) { - vector<int> ans, seen(n); - for (auto e : edges) - seen[e[1]] = 1; - for (int i = 0; i < n; ++i) - if (!seen[i]) - ans.push_back(i); - return ans; - } -}; - -int main() { - Solution obj; - vvd e1 = {{0, 1}, {0, 2}, {2, 5}, {3, 4}, {4, 2}}; - vvd e2 = {{0, 1}, {2, 1}, {3, 1}, {1, 4}, {2, 4}}; - for (auto i : obj.findSmallestSetOfVertices(6, e1)) - printf("%d ", i); // expect: 0 3 - printf("\n"); - for (auto i : obj.findSmallestSetOfVertices(5, e2)) - printf("%d ", i); // expect: 0 2 3 -} |