commit 30bdd949e3c8839eafabfb96572fdac0c8c872bd
parent b829c7454fe67818bb280544ae9bedfc78b2ca88
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 21 Aug 2024 18:35:18 +0200
1 Random Problem
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Problems/3137.cpp b/Problems/3137.cpp
@@ -0,0 +1,14 @@
+class Solution {
+ public:
+ int minimumOperationsToMakeKPeriodic(const string &word, int k) const {
+ unordered_map<string, int> um;
+ const int n = size(word);
+ int maxi = 0;
+
+ for (int i = 0; i < n; i += k) {
+ maxi = max(maxi, ++um[word.substr(i, k)]);
+ }
+
+ return n / k - maxi;
+ }
+};
diff --git a/README.md b/README.md
@@ -1315,6 +1315,7 @@ for solving problems.
| 3106 | Medium | [Lexicographically Smallest String After Operations With Constraint](Problems/3106.cpp) |
| 3110 | Easy | [Score of a String](Problems/3110.cpp) |
| 3111 | Medium | [Minimum Rectangles to Cover Points](Problems/3111.cpp) |
+| 3137 | Medium | [Minimum Number of Operations to Make Word K-Periodic](Problems/3137.cpp) |
| 3159 | Medium | [Find Occurrences of an Element in an Array](Problems/3159.cpp) |
| 3190 | Easy | [Find Minimum Operations to Make All Elements Divisible by Three](Problems/3190.cpp) |
| 3191 | Medium | [Minimum Operations to Make Binary Array Elements Equal to One I](Problems/3191.cpp) |