leetcodeSolution to some Leetcode problems written in C++ | 
          
| git clone git://git.dimitrijedobrota.com/leetcode.git | 
| Log | Files | Refs | README | LICENSE | 
| commit | d6f9f9640685b1981e776c400aa26e1f224064f3 | 
| parent | dde62c66f3c34cd052c4303bd474ec265586f6b7 | 
| author | Dimitrije Dobrota < mail@dimitrijedobrota.com > | 
| date | Thu, 7 Mar 2024 18:39:35 +0000 | 
2 Random Problems
| A | Problems/3016.cpp | | | +++++++++++++++++ | 
| A | Problems/3034.cpp | | | +++++++++++++++++++ | 
| M | README.md | | | ++ | 
3 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/ Problems/3016.cpp b/ Problems/3016.cpp
@@ -0,0 +1,17 @@
class Solution {
            public:
              int minimumPushes(const string &word) const {
                  int count[26] = {0};
                  for (const char c : word)
                      count[c - 'a']++;
                  sort(count, count + 26, greater());
                  int res = 0, key = 1, cnt = 0;
                  for (int i = 0; i < 26; i++) {
                      res += key * count[i];
                      if (++cnt == 8) key++, cnt = 0;
                  }
                  return res;
              }
          };
        
        diff --git a/ Problems/3034.cpp b/ Problems/3034.cpp
@@ -0,0 +1,19 @@
class Solution {
            public:
              int countMatchingSubarrays(const vector<int> &nums, const vector<int> &pattern) const {
                  const int n = size(nums), m = size(pattern);
                  int res = 0;
                  for (int i = 1; i <= n - m; i++) {
                      for (int j = 0; j < m; j++) {
                          if (pattern[j] == -1 && nums[i + j] >= nums[i + j - 1]) goto next;
                          if (pattern[j] == 0 && nums[i + j] != nums[i + j - 1]) goto next;
                          if (pattern[j] == 1 && nums[i + j] <= nums[i + j - 1]) goto next;
                      }
                      res++;
                  next:;
                  }
                  return res;
              }
          };
        
        diff --git a/ README.md b/ README.md
          @@ -1152,4 +1152,6 @@ 
          for solving problems.
        
        
          |  2971  |   Medium   | [Find Polygon With the Largest Perimeter](Problems/2971.cpp)                                       |
          |  2997  |   Medium   | [Minimum Number of Operations to Make Array XOR Equal to K](Problems/2997.cpp)                     |
          |  3015  |   Medium   | [Count the Number of Houses at a Certain Distance I](Problems/3015.cpp)                            |
          |  3016  |   Medium   | [Minimum Number of Pushes to Type Word II](Problems/3016.cpp)                                      |
          |  3034  |   Medium   | [Number of Subarrays That Match a Pattern I](Problems/3034.cpp)                                    |
          |  3039  |   Medium   | [Apply Operations to Make String Empty](Problems/3039.cpp)                                         |