commit 8a16ebbaffbff220b3207ef55188b3855109c828
parent 5b33588e53ebdc8e59ad1ef729e7b489e1d78250
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 10 Oct 2023 20:07:30 +0000
Daily Problem
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Problems/2009.cpp b/Problems/2009.cpp
@@ -0,0 +1,16 @@
+class Solution {
+ public:
+ int minOperations(vector<int> &nums) const {
+ const int n = nums.size();
+ sort(begin(nums), end(nums));
+ nums.erase(unique(nums.begin(), nums.end()), nums.end());
+
+ int res = INT_MIN, j = 0;
+ for (int i = 0; i < nums.size(); i++) {
+ while (j < nums.size() && nums[j] < nums[i] + n)
+ j++;
+ res = max(res, j - i);
+ }
+ return n - res;
+ }
+};
diff --git a/README.md b/README.md
@@ -738,6 +738,7 @@ for solving problems.
| 1980 | Medium | [Find Unique Binary String](Problems/1980.cpp) |
| 1991 | Easy | [Find the Middle Index in Array](Problems/1991.cpp) |
| 1992 | Medium | [Find All Groups of Farmland](Problems/1992.cpp) |
+| 2009 | Hard | [Minimum Number of Operations to Make Array Continuous](Problems/2009.cpp) |
| 2023 | Medium | [Number of Pairs of Strings With Concatenation Equal to Target](Problems/2023.cpp) |
| 2024 | Medium | [Maximize the Confusion of an Exam](Problems/2024.cpp) |
| 2038 | Medium | [Remove Colored Pieces if Both Neighbors are the Same Color](Problems/2038.cpp) |