leetcode

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

commit 7af105c388d2402e0e59522a6aad325899241266
parent 95e2ee4efc673fe98b1ec3a561a56aa538ba87e7
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 26 Aug 2024 23:35:37 +0200

1 Random Problem

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

diff --git a/Problems/3218.cpp b/Problems/3218.cpp @@ -0,0 +1,14 @@ +class Solution { + public: + int minimumCost(int n, int m, const vector<int> &hCut, const vector<int> &vCut) const { + int res = accumulate(begin(hCut), end(hCut), 0) + accumulate(begin(vCut), end(vCut), 0); + + for (const int a : hCut) { + for (const int b : vCut) { + res += min(a, b); + } + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1328,6 +1328,7 @@ for solving problems. | 3211 | Medium | [Generate Binary Strings Without Adjacent Zeros](Problems/3211.cpp) | | 3212 | Medium | [Count Submatrices With Equal Frequency of X and Y](Problems/3212.cpp) | | 3217 | Medium | [Delete Nodes From Linked List Present in Array](Problems/3217.cpp) | +| 3218 | Medium | [Minimum Cost for Cutting Cake I](Problems/3218.cpp) | | 3227 | Medium | [Vowels Game in a String](Problems/3227.cpp) | | 3228 | Medium | [Maximum Number of Operations to Move Ones to the End](Problems/3228.cpp) | | 3239 | Medium | [Minimum Number of Flips to Make Binary Grid Palindromic I](Problems/3239.cpp) |