2341. Maximum Number of Pairs in Array, Leetcode 中文解說

Опубликовано: 08 Август 2026
на канале: Billour Ou
180
0

Leetcode Weekly Contest 302
2341. Maximum Number of Pairs in Array, My C++ code is Accepted.
中文解說


You are given a 0-indexed integer array nums. In one operation, you may do the following:

Choose two integers in nums that are equal.
Remove both integers from nums, forming a pair.
The operation is done on nums as many times as possible.

Return a 0-indexed integer array answer of size 2 where answer[0] is the number of pairs that are formed and answer[1] is the number of leftover integers in nums after doing the operation as many times as possible.



https://leetcode.com/problems/maximum...