leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | c019d3b4af649862b7562a91c8de9426b63997ff |
parent | f40a78147065563d15bdb917138da9e0f46861f1 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Sat, 19 Oct 2024 09:15:32 +0200 |
1 Random Problem
Diffstat:A | Problems/2011.cpp | | | +++++++++++++++ |
M | README.md | | | + |
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2011.cpp b/Problems/2011.cpp
@@ -0,0 +1,15 @@
class Solution {
public:
int finalValueAfterOperations(const vector<string> &operations) const {
int res = 0;
for (const auto &op : operations) {
if (op.front() == '-' || op.back() == '-')
res--;
else
res++;
}
return res;
}
};
diff --git a/README.md b/README.md
@@ -1090,6 +1090,7 @@ for solving problems.
| 2001 | Medium | [Number of Pairs of Interchangeable Rectangles](Problems/2001.cpp) |
| 2002 | Medium | [Maximum Product of the Length of Two Palindromic Subsequences](Problems/2002.cpp) |
| 2009 | Hard | [Minimum Number of Operations to Make Array Continuous](Problems/2009.cpp) |
| 2011 | Easy | [Final Value of Variable After Performing Operations](Problems/2011.cpp) |
| 2013 | Medium | [Detect Squares](Problems/2013.cpp) |
| 2022 | Easy | [Convert 1D Array Into 2D Array](Problems/2022.cpp) |
| 2023 | Medium | [Number of Pairs of Strings With Concatenation Equal to Target](Problems/2023.cpp) |