From 7c60dee83b436e8e8a667bf9f191beced8de4fc3 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Mon, 10 Mar 2025 00:36:13 -0600 Subject: chore: move cpp and rust code to directory --- other/min_rounds_complete_all_tasks.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 other/min_rounds_complete_all_tasks.cpp (limited to 'other/min_rounds_complete_all_tasks.cpp') diff --git a/other/min_rounds_complete_all_tasks.cpp b/other/min_rounds_complete_all_tasks.cpp new file mode 100644 index 0000000..0d78073 --- /dev/null +++ b/other/min_rounds_complete_all_tasks.cpp @@ -0,0 +1,27 @@ +#include "leetcode.h" + +class Solution { +public: + int minimumRounds(vector &tasks) { + unordered_map um; + for (auto i : tasks) + um[i]++; + int count = 0; + for (auto i : um) { + int t = i.second; + if (t == 1) + return -1; + count += t / 3; + if (t % 3 != 0) + count++; + } + return count; + } +}; + +int main() { + Solution obj; + vector tasks1 = {2, 2, 3, 3, 2, 4, 4, 4, 4, 4}, tasks2 = {2, 3, 3}; + cout << obj.minimumRounds(tasks1) << endl; + cout << obj.minimumRounds(tasks2) << endl; +} -- cgit v1.2.3