leetcode

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

commit b68b2972a1f5912e4811d7464330e62c12ced158
parent 11fbc78c9ecd469905023378c0682a2f23023b52
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue,  5 Mar 2024 15:33:34 +0000

Daily Problem

Diffstat:
AProblems/1750.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/1750.cpp b/Problems/1750.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + int minimumLength(const string &s) const { + int i = 0, j = size(s) - 1; + while (i < j && s[i] == s[j]) { + const int goal = s[i]; + while (i <= j && s[i] == goal) + i++; + while (i < j && s[j] == goal) + j--; + } + + return j - i + 1; + } +}; diff --git a/README.md b/README.md @@ -887,6 +887,7 @@ for solving problems. | 1741 | Easy | [Find Total Time Spent by Each Employee](Problems/1741.cpp) | | 1743 | Medium | [Restore the Array From Adjacent Pairs](Problems/1743.cpp) | | 1749 | Medium | [Maximum Absolute Sum of Any Subarray](Problems/1749.cpp) | +| 1750 | Medium | [Minimum Length of String After Deleting Similar Ends](Problems/1750.cpp) | | 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) |