leetcode

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

commit c69cdb8dc8b58d2a5e0f48e95a1b731eb6e6dc26
parent 9098316af92bd6430dc55ee1ab89a5bd47abf1b4
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 28 Aug 2024 19:05:25 +0200

1 Random Problem

Diffstat:
AProblems/3223.cpp | 17+++++++++++++++++
MREADME.md | 1+
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Problems/3223.cpp b/Problems/3223.cpp @@ -0,0 +1,17 @@ +class Solution { + public: + int minimumLength(const string &s) const { + int count[26] = {0}; + int res = 0; + + for (const char c : s) { + count[c - 'a']++; + } + + for (int i = 0; i < 26; i++) { + res += (count[i] - 1) / 2; + } + + return size(s) - 2 * res; + } +}; diff --git a/README.md b/README.md @@ -1329,6 +1329,7 @@ for solving problems. | 3212 | Medium | [Count Submatrices With Equal Frequency of X and Y](Problems/3212.cpp) | | 3217 | Medium | [Delete Nodes From Linked List Present in Array](Problems/3217.cpp) | | 3218 | Medium | [Minimum Cost for Cutting Cake I](Problems/3218.cpp) | +| 3223 | Medium | [Minimum Length of String After Operations](Problems/3223.cpp) | | 3227 | Medium | [Vowels Game in a String](Problems/3227.cpp) | | 3228 | Medium | [Maximum Number of Operations to Move Ones to the End](Problems/3228.cpp) | | 3239 | Medium | [Minimum Number of Flips to Make Binary Grid Palindromic I](Problems/3239.cpp) |