leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

3137.cpp (344B)


      1 class Solution {
      2   public:
      3     int minimumOperationsToMakeKPeriodic(const string &word, int k) const {
      4         unordered_map<string, int> um;
      5         const int n = size(word);
      6         int maxi = 0;
      7 
      8         for (int i = 0; i < n; i += k) {
      9             maxi = max(maxi, ++um[word.substr(i, k)]);
     10         }
     11 
     12         return n / k - maxi;
     13     }
     14 };