From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/min_deviation_arr.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 other/min_deviation_arr.cpp (limited to 'other/min_deviation_arr.cpp') diff --git a/other/min_deviation_arr.cpp b/other/min_deviation_arr.cpp deleted file mode 100644 index 47099a6..0000000 --- a/other/min_deviation_arr.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// 1675. Minimize Deviation in Array -#include "leetcode.h" - -/* - * the deviation of the array is the maximum difference between any two elements - * in the array. return minimum deviation the array can have after performing - * 'nums' ops. - */ - -class Solution { -public: - int minimumDeviation(vector nums) { - int ans = INT_MAX, min_nums = INT_MAX; - for (int i = 0; i < nums.size(); ++i) { - nums[i] = nums[i] % 2 ? nums[i] * 2 : nums[i]; - min_nums = min(min_nums, nums[i]); - } - make_heap(begin(nums), end(nums)); - while (nums[0] % 2 == 0) { - ans = min(ans, nums[0] - min_nums); - min_nums = min(min_nums, nums[0] / 2); - pop_heap(begin(nums), end(nums)); - nums.back() /= 2; - push_heap(begin(nums), end(nums)); - } - return min(ans, nums[0] - min_nums); - } -}; - -int main() { - Solution obj; - vector n1 = {1, 2, 3, 4}, n2 = {4, 1, 5, 20, 3}, n3 = {2, 10, 8}; - cout << obj.minimumDeviation(n1) << endl; // expect: 1 - cout << obj.minimumDeviation(n2) << endl; // expect: 3 - cout << obj.minimumDeviation(n3) << endl; // expect: 3 -} -- cgit v1.2.3