Skip to content

Commit d8b8359

Browse files
authored
Merge pull request neetcode-gh#2672 from flashzzz/main
Create 2554-maximum-number-of-integers-to-choose-from-a-range-I.py
2 parents 2bc2fd9 + 66b72f3 commit d8b8359

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:
3+
nums = {x:1 for x in range(1, n + 1)} # hashmap for storing the required elements
4+
for i in banned:
5+
if nums.get(i):
6+
del nums[i]
7+
sum = 0
8+
count = 0
9+
for i in nums:
10+
sum += i
11+
if sum <= maxSum:
12+
count += 1
13+
else:
14+
break
15+
return count

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy