leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 022db97f36ed64d75a85eea481f3fc33beade83e |
parent | 3e6d91298e2a97ca8c2b7c5d61741592a353ab2a |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Thu, 15 Feb 2024 22:07:25 +0000 |
Daily Problem
Diffstat:A | Problems/2971.cpp | | | ++++++++++++++ |
M | README.md | | | + |
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Problems/2971.cpp b/Problems/2971.cpp
@@ -0,0 +1,14 @@
class Solution {
public:
long long largestPerimeter(vector<int> &nums) const {
sort(begin(nums), end(nums));
long long res = -1, crnt = 0;
for (int i = 0; i < size(nums); i++) {
crnt += nums[i];
if (crnt > nums[i] * 2) res = crnt;
}
return res;
}
};
diff --git a/README.md b/README.md
@@ -1130,5 +1130,6 @@ for solving problems.
| 2924 | Medium | [Find Champion II](Problems/2924.cpp) |
| 2947 | Medium | [Count Beautiful Substrings I](Problems/2947.cpp) |
| 2966 | Medium | [Divide Array Into Arrays With Max Difference](Problems/2966.cpp) |
| 2971 | Medium | [Find Polygon With the Largest Perimeter](Problems/2971.cpp) |
| 2997 | Medium | [Minimum Number of Operations to Make Array XOR Equal to K](Problems/2997.cpp) |
| 3015 | Medium | [Count the Number of Houses at a Certain Distance I](Problems/3015.cpp) |