Skip to content

Commit a4244df

Browse files
committed
Dec 6
1 parent ffcb1b3 commit a4244df

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:
6+
banned = set(banned)
7+
s, count = 0, 0
8+
for i in range(1, n+1):
9+
if i not in banned:
10+
if s+i > maxSum:
11+
return count
12+
count += 1
13+
s += i
14+
return count
15+
16+
17+
def main():
18+
banned = [1, 6, 5]
19+
n = 5
20+
maxSum = 6
21+
assert Solution().maxCount(banned, n, maxSum) == 2
22+
23+
banned = [1, 2, 3, 4, 5, 6, 7]
24+
n = 8
25+
maxSum = 1
26+
assert Solution().maxCount(banned, n, maxSum) == 0
27+
28+
banned = [11]
29+
n = 7
30+
maxSum = 50
31+
assert Solution().maxCount(banned, n, maxSum) == 7
32+
33+
34+
if __name__ == '__main__':
35+
main()

2024-12-December-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| December 3 | [2109. Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string/) | Medium | Solved |
99
| December 4 | [2825. Make String a Subsequence Using Cyclic Increments](https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/) | Medium | Solved |
1010
| December 5 | [2337. Move Pieces to Obtain a String](https://leetcode.com/problems/move-pieces-to-obtain-a-string/) | Medium | Unsolved |
11-
| December 6 | []() | | |
11+
| December 6 | [2554. Maximum Number of Integers to Choose From a Range I](https://leetcode.com/problems/maximum-number-of-integers-to-choose-from-a-range-i/) | Medium | Solved |
1212
| December 7 | []() | | |
1313
| December 8 | []() | | |
1414
| December 9 | []() | | |
@@ -39,5 +39,5 @@
3939
| Level | Problems | Solved | Unsolved |
4040
| --- | --- | --- | --- |
4141
| Easy | 2 | 2 | 0 |
42-
| Medium | 3 | 2 | 1 |
42+
| Medium | 4 | 3 | 1 |
4343
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)