leetcode

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

commit 70fe27284059abfe0f4ed261d425a6eb05d2d1fd
parent 20eb2b305ef509a7ca401894634abe3628c40ba2
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 22 Jun 2024 13:24:39 +0200

1 Random Problem

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

diff --git a/Problems/2380.cpp b/Problems/2380.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + int secondsToRemoveOccurrences(const string &s) const { + int res = 0, count = 0; + + for (int i = 0; i < s.size(); ++i) { + if (s[i] == '0') + count++; + else if (count) + res = max(res + 1, count); + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1130,6 +1130,7 @@ for solving problems. | 2373 | Easy | [Largest Local Values in a Matrix](Problems/2373.cpp) | | 2374 | Medium | [Node With Highest Edge Score](Problems/2374.cpp) | | 2375 | Medium | [Construct Smallest Number From DI String](Problems/2375.cpp) | +| 2380 | Medium | [Time Needed to Rearrange a Binary String](Problems/2380.cpp) | | 2385 | Medium | [Amount of Time for Binary Tree to Be Infected](Problems/2385.cpp) | | 2390 | Medium | [Removing Stars From a String](Problems/2390.cpp) | | 2391 | Medium | [Minimum Amount of Time to Collect Garbage](Problems/2391.cpp) |