Maximum Number of Pairs in Array LeetCode solution in Python

1
class Solution:
2
def numberOfPairs(self, nums: List[int]) -> List[int]:
3
ans = [0] * 2
4
c = Counter(nums)
5

6
for v in c.values():
7
ans[0] += v // 2
8
ans[1] += v % 2
9

10
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0