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_time_apples_tree.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/min_time_apples_tree.cpp')
-rw-r--r-- | other/min_time_apples_tree.cpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/other/min_time_apples_tree.cpp b/other/min_time_apples_tree.cpp deleted file mode 100644 index 81d97d7..0000000 --- a/other/min_time_apples_tree.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int minTime(int n, vvd & edges, vector<bool> &hasApple) { - unordered_map<int, int> um; - int ans = 0; - sort(edges.begin(), edges.end()); - for (auto const &e : edges) { - if (um.count(e[1]) > 0) - um[e[0]] = e[1]; - else - um[e[1]] = e[0]; - } - for (int i = 0; i < hasApple.size(); ++i) { - if (!hasApple[i]) - continue; - int parent = i; - while (parent != 0 && um[parent] >= 0) { - auto tmp = um[parent]; - um[parent] = -1; - parent = tmp; - ans += 2; - } - } - return ans; - } -}; - -int main() { - Solution obj; - vvd edges = {{0, 1}, {0, 2}, {1, 4}, {1, 5}, {2, 3}, {2, 6}}; - vector<bool> hasApple1 = {false, false, true, false, true, true, false}, - hasApple2 = {false, false, true, false, false, true, false}, - hasApple3 = {false, false, false, false, false, false, false}; - cout << obj.minTime(7, edges, hasApple1) << endl; // expect: 8 - cout << obj.minTime(7, edges, hasApple2) << endl; // expect: 6 - cout << obj.minTime(7, edges, hasApple3) << endl; // expect: 0 -} |