Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8203611

Browse filesBrowse files
authored
Create 18 maxNumKSumPairs.py
1 parent a040494 commit 8203611
Copy full SHA for 8203611

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎January 2021/18 maxNumKSumPairs.py

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def maxOperations(self, nums: List[int], k: int) -> int:
3+
4+
cnt, ans = Counter(nums), 0
5+
for val in cnt:
6+
ans += min(cnt[val], cnt[k - val])
7+
8+
return ans//2

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.