leetcode

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

commit fc43600dad3d0c31852434baad1426bf8b9eaa12
parent 41106b7d05838a8589efe24fed2e5447b5ca6b64
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun, 24 Dec 2023 23:19:49 +0000

Daily Problem

Diffstat:
AProblems/1758.cpp | 11+++++++++++
MREADME.md | 1+
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Problems/1758.cpp b/Problems/1758.cpp @@ -0,0 +1,11 @@ +class Solution { + public: + int minOperations(const string &s) const { + int num = 0, crnt = 1; + for (const char c : s) { + if ((c & 0xF) != crnt) num++; + crnt = !crnt; + } + return min(num, (int)size(s) - num); + } +}; diff --git a/README.md b/README.md @@ -819,6 +819,7 @@ for solving problems. | 1751 | Hard | [Maximum Number of Events That Can Be Attended II](Problems/1751.cpp) | | 1753 | Medium | [Maximum Score From Removing Stones](Problems/1753.cpp) | | 1757 | Easy | [Recyclable and Low Fat Products](Problems/1757.cpp) | +| 1758 | Easy | [Minimum Changes To Make Alternating Binary String](Problems/1758.cpp) | | 1759 | Medium | [Count Number of Homogenous Substrings](Problems/1759.cpp) | | 1760 | Medium | [Minimum Limit of Balls in a Bag](Problems/1760.cpp) | | 1765 | Medium | [Map of Highest Peak](Problems/1765.cpp) |