aboutsummaryrefslogtreecommitdiff
path: root/other/min_num_opp_arr_cont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/min_num_opp_arr_cont.cpp')
-rw-r--r--other/min_num_opp_arr_cont.cpp22
1 files changed, 0 insertions, 22 deletions
diff --git a/other/min_num_opp_arr_cont.cpp b/other/min_num_opp_arr_cont.cpp
deleted file mode 100644
index 5dcb40f..0000000
--- a/other/min_num_opp_arr_cont.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- int minOperations(vector<int> &nums) {
- int n = nums.size(), ans = n, j = 0;
- sort(nums.begin(), nums.end());
- nums.erase(unique(nums.begin(), nums.end()), nums.end());
- for (int i = 0; i < nums.size(); ++i) {
- while (j < nums.size() && nums[j] < nums[i] + n)
- ++j;
- ans = min(ans, n - j + i);
- }
- return ans;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> nums = {4, 2, 5, 3};
- cout << obj.minOperations(nums);
-}