leetcode

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

commit ee9a007f588e4b0b04254508c5f215e8893193c4
parent 1862ef041e14f0472f065b3da40d77f921c95646
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 13 May 2024 17:44:11 +0200

1 Random Problem

Diffstat:
AProblems/2957.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/2957.cpp b/Problems/2957.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + int removeAlmostEqualCharacters(const string &word) const { + int res = 0; + + for (int i = 0; i < size(word) - 1; i++) { + if (abs(word[i] - word[i + 1]) > 1) continue; + res++, i++; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1208,6 +1208,7 @@ for solving problems. | 2938 | Medium | [Separate Black and White Balls](Problems/2938.cpp) | | 2947 | Medium | [Count Beautiful Substrings I](Problems/2947.cpp) | | 2952 | Medium | [Minimum Number of Coins to be Added](Problems/2952.cpp) | +| 2957 | Medium | [Remove Adjacent Almost-Equal Characters](Problems/2957.cpp) | | 2958 | Medium | [Length of Longest Subarray With at Most K Frequency](Problems/2958.cpp) | | 2962 | Medium | [Count Subarrays Where Max Element Appears at Least K Times](Problems/2962.cpp) | | 2966 | Medium | [Divide Array Into Arrays With Max Difference](Problems/2966.cpp) |