leetcode

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

commit 66bd23394c5e1386f75e07a36b03e16c18aa7d0d
parent 15a1f85af72bc9d92154b9d2e5788b417cc7fe62
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 20 Mar 2024 16:32:43 +0000

1 Random Problems

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

diff --git a/Problems/2938.cpp b/Problems/2938.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + long long minimumSteps(const string &s) const { + long long res = 0; + + for (int i = 0, cnt = 0; i < size(s); i++) { + if (s[i] & 1) + cnt++; + else + res += cnt; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1158,6 +1158,7 @@ for solving problems. | 2900 | Medium | [Longest Unequal Adjacent Groups Subsequence I](Problems/2900.cpp) | | 2914 | Medium | [Minimum Number of Changes to Make Binary String Beautiful](Problems/2914.cpp) | | 2924 | Medium | [Find Champion II](Problems/2924.cpp) | +| 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) | | 2966 | Medium | [Divide Array Into Arrays With Max Difference](Problems/2966.cpp) |