leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | ef88eba3d2a3e81f612772dfdd0cd13cd61f3d53 |
parent | 7457990da896d45e2655a56ebaaa92b8b4117050 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Mon, 6 May 2024 07:18:52 +0200 |
1 Random Problem
Diffstat:A | Problems/2274.cpp | | | +++++++++++++++++ |
M | README.md | | | + |
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Problems/2274.cpp b/Problems/2274.cpp
@@ -0,0 +1,17 @@
class Solution {
public:
int maxConsecutive(int bottom, int top, vector<int> &special) const {
int res = 0, i;
sort(begin(special), end(special));
for (i = 0; i < size(special); i++)
if (special[i] >= bottom) break;
for (; i < size(special); i++) {
if (special[i] > top) break;
res = max(res, special[i] - bottom);
bottom = special[i] + 1;
}
return max(res, top - bottom + 1);
}
};
diff --git a/README.md b/README.md
@@ -1062,6 +1062,7 @@ for solving problems.
| 2265 | Medium | [Count Nodes Equal to Average of Subtree](Problems/2265.cpp) |
| 2265 | Medium | [Count Nodes Equal to Average of Subtree](Problems/2265.cpp) |
| 2272 | Hard | [Substring With Largest Variance](Problems/2272.cpp) |
| 2274 | Medium | [Maximum Consecutive Floors Without Special Floors](Problems/2274.cpp) |
| 2275 | Medium | [Largest Combination With Bitwise AND Greater Than Zero](Problems/2275.cpp) |
| 2279 | Medium | [Maximum Bags With Full Capacity of Rocks](Problems/2279.cpp) |
| 2284 | Medium | [Sender With Largest Word Count](Problems/2284.cpp) |