FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 2421,3 "name": "maximum_number_of_pairs_in_array",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/maximum-number-of-pairs-in-array/",6 "date": "1657411200000",7 "task_description": "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_. **Example 1:** ``` **Input:** nums = [1,3,2,1,3,2,2] **Output:** [3,1] **Explanation:** Form a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2]. Form a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2]. Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2]. No more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums. ``` **Example 2:** ``` **Input:** nums = [1,1] **Output:** [1,0] **Explanation:** Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = []. No more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums. ``` **Example 3:** ``` **Input:** nums = [0] **Output:** [0,1] **Explanation:** No pairs can be formed, and there is 1 number leftover in nums. ``` **Constraints:** `1 <= nums.length <= 100` `0 <= nums[i] <= 100`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [1,3,2,1,3,2,2]",12 "output": "[3,1] "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,1]",17 "output": "[1,0] "18 },19 {20 "label": "Example 3",21 "input": "nums = [0]",22 "output": "[0,1] "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 9,29 66,30 34,31 41,32 77,33 39,34 45,35 26,36 95,37 66,38 26,39 43,40 23,41 75,42 68,43 89,44 30,45 47,46 46,47 62,48 58,49 49,50 87,51 75,52 14,53 70,54 62,55 53,56 8,57 58,58 30,59 2,60 19,61 89,62 26,63 52,64 93,65 6,66 21,67 15,68 55,69 40,70 38,71 34,72 15,73 65,74 87,75 9,76 80,77 5,78 17,79 70,80 86,81 18,82 46,83 17,84 31,85 91,86 61,87 77,88 6,89 78,90 97,91 51,92 51,93 34,94 41,95 75,96 54,97 19,98 51,99 58,100 1,101 11,102 37,103 98,104 65,105 11,106 54,107 8,108 75,109 98,110 48,111 45,112 87,113 66,114 52,115 51,116 97,117 20,118 46,119 89,120 18,121 6,122 15,123 38124 ],125 "output": [126 31,127 34128 ]129 },130 {131 "input": [132 82,133 95,134 63,135 74,136 27,137 87,138 85,139 77,140 62,141 97,142 100,143 8,144 63,145 89,146 50,147 76,148 60,149 69,150 65,151 12,152 58,153 32,154 78,155 25,156 18,157 70,158 73,159 97,160 28,161 99,162 81,163 58,164 98,165 82,166 44,167 55,168 2,169 81,170 81,171 22,172 86,173 95,174 14,175 66,176 29,177 52,178 95,179 50,180 26,181 68,182 32183 ],184 "output": [185 8,186 35187 ]188 },189 {190 "input": [191 15,192 77,193 39,194 78,195 42,196 15,197 77,198 20,199 59,200 55,201 30,202 0,203 7,204 23,205 77,206 11,207 69,208 56,209 16,210 55,211 30,212 48,213 22,214 88,215 34216 ],217 "output": [218 4,219 17220 ]221 },222 {223 "input": [224 20,225 75,226 25,227 100,228 75,229 0,230 44,231 23,232 0,233 100,234 88,235 48,236 49,237 53,238 36,239 6,240 45,241 51,242 34,243 30,244 45,245 51,246 99,247 33,248 4,249 14,250 33,251 90,252 38,253 99,254 96,255 2,256 11,257 14,258 20,259 42,260 82,261 0,262 11,263 12264 ],265 "output": [266 10,267 20268 ]269 },270 {271 "input": [272 12,273 86,274 9,275 9,276 5,277 59,278 20,279 99,280 77,281 57,282 28,283 60,284 54,285 37,286 7,287 4288 ],289 "output": [290 1,291 14292 ]293 },294 {295 "input": [296 79,297 77298 ],299 "output": [300 0,301 2302 ]303 },304 {305 "input": [306 99,307 58,308 88,309 28,310 4,311 73,312 17,313 40,314 70315 ],316 "output": [317 0,318 9319 ]320 },321 {322 "input": [323 21,324 69,325 95,326 27,327 66,328 75,329 89,330 67,331 47,332 19,333 42,334 74,335 70,336 83,337 71,338 32,339 31,340 63,341 83,342 8,343 21,344 37,345 55,346 51,347 45,348 29,349 69,350 49,351 0,352 22,353 27,354 37,355 8,356 91,357 56,358 69,359 84,360 13,361 100,362 19,363 49,364 85,365 4,366 25,367 14,368 76,369 73,370 57,371 70,372 50,373 40,374 21,375 15,376 54,377 32,378 27,379 9,380 85,381 99,382 14,383 41,384 31385 ],386 "output": [387 13,388 36389 ]390 },391 {392 "input": [393 10,394 16,395 3,396 65,397 76,398 9,399 79,400 74,401 29,402 86,403 4,404 22,405 44,406 79,407 60,408 80,409 46,410 13,411 35,412 14,413 63,414 39,415 76,416 29,417 91,418 68,419 4,420 18,421 48,422 47,423 12,424 41,425 85,426 88,427 47,428 8,429 87,430 94,431 12,432 51,433 36,434 94,435 42,436 95,437 52,438 31,439 87,440 48,441 85,442 22,443 62,444 21,445 43,446 40,447 96,448 41,449 84,450 35,451 63,452 78,453 87,454 47,455 42,456 0,457 6,458 8,459 58,460 60,461 69,462 34,463 73,464 84,465 69,466 29,467 10,468 82,469 81,470 8,471 75,472 27,473 73,474 56,475 69476 ],477 "output": [478 21,479 41480 ]481 },482 {483 "input": [484 67,485 46,486 53,487 9,488 91,489 39,490 42,491 41,492 25,493 54,494 91,495 15,496 10,497 30,498 74,499 71,500 76,501 95,502 22,503 66,504 49,505 25,506 96,507 64,508 9,509 2,510 52,511 61,512 1,513 33,514 53,515 17,516 86,517 13,518 13,519 17,520 57521 ],522 "output": [523 6,524 25525 ]526 }527 ],528 "haskell_template": "numberOfPairs :: [Int] -> [Int]\nnumberOfPairs nums ",529 "ocaml_template": "let numberOfPairs (nums: int list) : int list = ",530 "scala_template": "def numberOfPairs(nums: List[Int]): List[Int] = { \n \n}",531 "java_template": "public static List<Integer> numberOfPairs(List<Integer> nums) {\n\n}",532 "python_template": "class Solution(object):\n def numberOfPairs(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "533}