You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/docs/CommunityShare/Leetcode/2341. 数组能形成多少数对_translated.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,25 +4,30 @@ tags:
4
4
- - Python
5
5
- - answer
6
6
abbrlink: f953c753
7
-
date: '2024.01.01 0:00'
7
+
date: "2024.01.01 0:00"
8
+
docId: s3w19zdm6yhkhj4o0ba3kbal
8
9
---
9
10
10
11
# topic:
11
12
12
13
[2341. How much can the array be formed.md](https://leetcode.cn/problems/maximum-number-of-pairs-in-array/description/)
13
14
14
15
# Thought:
16
+
15
17
## I am:
18
+
16
19
I don't know if I saw it“Simple”Two words,This question has the initiative to think about the optimal solution。Actually this timeylbBig guy's hash table method is still fast。
17
20
Sort the list,Whether two or two are equal to whether。
21
+
18
22
## Hash tableThought:
23
+
19
24
CounterAfter counting,`a+=v//2`,`b+=v%2`For each number x,
20
25
if x Number of times v more than the 1,You can choose two from the array x Form a number pair,we willv Divide 2 Take down,
21
26
You can get the current number x Number pairs that can be formed,Then we accumulate this number to the variable s middle。
0 commit comments