leetcode

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

commita6b81c8329e1bb388ca0ac282047064f48632375
parentcc043aa2a286a0b70ef2bfb3c69110370a562617
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateSat, 30 Mar 2024 21:37:47 +0000

1 Random Problem

Diffstat:
AProblems/2554.cpp|++++++++++++++++
MREADME.md|+

2 files changed, 17 insertions(+), 0 deletions(-)


diff --git a/Problems/2554.cpp b/Problems/2554.cpp

@@ -0,0 +1,16 @@

class Solution {
public:
int maxCount(const vector<int> &banned, int n, int maxSum) const {
unordered_set<int> us(begin(banned), end(banned));
int res = 0, sum = 0;
for (int i = 1; i <= n; i++) {
if (us.count(i)) continue;
sum += i;
if (sum > maxSum) return res;
res++;
}
return res;
}
};

diff --git a/README.md b/README.md

@@ -1109,6 +1109,7 @@ for solving problems.

| 2542 | Medium | [Maximum Subsequence Score](Problems/2542.cpp) |
| 2545 | Medium | [Sort the Students by Their Kth Score](Problems/2545.cpp) |
| 2551 | Hard | [Put Marbles in Bags](Problems/2551.cpp) |
| 2554 | Medium | [Maximum Number of Integers to Choose From a Range I](Problems/2554.cpp) |
| 2568 | Medium | [Minimum Impossible OR](Problems/2568.cpp) |
| 2571 | Medium | [Minimum Operations to Reduce an Integer to 0](Problems/2571.cpp) |
| 2579 | Medium | [Count Total Number of Colored Cells](Problems/2579.cpp) |