leetcode

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

commit 67c9967c0b935971bc4c330ad95cb06c4f0e67ec
parent d9040a267fa0a3d89b6cb0f25f72c1c0fbb5d92f
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 18 Nov 2023 22:44:10 +0000

1 Random Problem

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

diff --git a/Problems/2178.cpp b/Problems/2178.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + vector<long long> maximumEvenSplit(long long finalSum) const { + if (finalSum % 2) return {}; + vector<long long> res; + for (long long crnt = 2; finalSum >= crnt; crnt += 2) { + res.push_back(crnt); + finalSum -= crnt; + } + res.back() += finalSum; + return res; + } +}; diff --git a/README.md b/README.md @@ -795,6 +795,7 @@ for solving problems. | 2155 | Medium | [All Divisions With the Highest Score of a Binary Array](Problems/2155.cpp) | | 2161 | Medium | [Partition Array According to Given Pivot](Problems/2161.cpp) | | 2177 | Medium | [Find Three Consecutive Integers That Sum to a Given Number](Problems/2177.cpp) | +| 2178 | Medium | [Maximum Split of Positive Even Integers](Problems/2178.cpp) | | 2181 | Medium | [Merge Nodes in Between Zeros](Problems/2181.cpp) | | 2186 | Medium | [Minimum Number of Steps to Make Two Strings Anagram II](Problems/2186.cpp) | | 2187 | Medium | [Minimum Time to Complete Trips](Problems/2187.cpp) |