TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 3094,3 "name": "minimum_number_of_operations_to_make_array_empty",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-empty/",6 "date": "2023-09-16 00:00:00",7 "task_description": "You are given a **0-indexed** array `nums` consisting of positive integers. There are two types of operations that you can apply on the array **any** number of times: Choose **two** elements with **equal** values and **delete** them from the array. Choose **three** elements with **equal** values and **delete** them from the array. Return _the **minimum** number of operations required to make the array empty, or _`-1`_ if it is not possible_. **Example 1:** ``` **Input:** nums = [2,3,3,2,2,4,2,3,4] **Output:** 4 **Explanation:** We can apply the following operations to make the array empty: - Apply the first operation on the elements at indices 0 and 3. The resulting array is nums = [3,3,2,4,2,3,4]. - Apply the first operation on the elements at indices 2 and 4. The resulting array is nums = [3,3,4,3,4]. - Apply the second operation on the elements at indices 0, 1, and 3. The resulting array is nums = [4,4]. - Apply the first operation on the elements at indices 0 and 1. The resulting array is nums = []. It can be shown that we cannot make the array empty in less than 4 operations. ``` **Example 2:** ``` **Input:** nums = [2,1,2,2,3,3] **Output:** -1 **Explanation:** It is impossible to empty the array. ``` **Constraints:** `2 <= nums.length <= 105` `1 <= nums[i] <= 106` **Note:** This question is the same as 2244: Minimum Rounds to Complete All Tasks.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [2,3,3,2,2,4,2,3,4]",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "nums = [2,1,2,2,3,3]",17 "output": "-1 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 939097,24 775354,25 623573,26 53772,27 785163,28 547762,29 971769,30 816369,31 811329,32 825964,33 834655,34 967637,35 854750,36 537958,37 583613,38 280258,39 169399,40 913462,41 166930,42 97069,43 111136,44 578287,45 308106,46 844229,47 991353,48 777564,49 873211,50 948056,51 625931,52 219304,53 720666,54 367046,55 293371,56 952433,57 876203,58 454184,59 966950,60 556513,61 477307,62 848469,63 67421,64 810735,65 854562,66 346655,67 698891,68 86015,69 834535,70 431606,71 316364,72 794299,73 533859,74 948089,75 81520,76 48141,77 667162,78 454000,79 200920,80 331399,81 472043,82 188051,83 181607,84 549796,85 248185,86 782941,87 357533,88 673661,89 289002,90 949507,91 724283,92 6529,93 503562,94 381352,95 400057,96 969251,97 349631,98 307859,99 445485,100 720369,101 235765,102 515747,103 708719,104 400190,105 81879,106 473095,107 765947,108 482091,109 623258,110 493317,111 638401,112 482904,113 655834,114 924324,115 716527,116 278882,117 661593,118 42853,119 890959,120 779800,121 259945,122 502607,123 383904,124 620854,125 631775,126 653390,127 544530,128 390400,129 514409,130 350637,131 443739,132 91569,133 12155,134 601267,135 197262,136 206064,137 530710,138 119226,139 44250,140 374016,141 530658,142 350068,143 599319,144 604092,145 605913,146 478012,147 759723,148 803103,149 183540,150 506760,151 46004,152 63388,153 200809,154 151286,155 173326,156 372530,157 557344,158 216162,159 602226,160 737413,161 927997,162 48718,163 225578,164 962549,165 41603,166 259367,167 176026,168 635858,169 427779,170 259818,171 586854,172 958431,173 621988,174 719282,175 696155,176 78597,177 31863,178 496987,179 459374,180 155127,181 158913,182 486604,183 928649,184 561556,185 497308,186 306113,187 339190,188 897208,189 506695,190 683855,191 219868,192 863993,193 706655,194 533611,195 282454,196 115412,197 858578,198 76232,199 657309,200 462119,201 299685,202 203161,203 560738,204 72094,205 237105,206 295980,207 171965,208 9884,209 215705,210 537778,211 140988,212 213682,213 228059,214 491893,215 167426,216 467905,217 360559,218 127726,219 790370,220 305388,221 315145,222 540710,223 770084,224 109596,225 560217,226 572157,227 676708,228 452458,229 564480,230 648071,231 895098,232 85556,233 456344,234 874170,235 691613,236 273245,237 854912,238 552870,239 316805,240 521764,241 154855,242 498266,243 345640,244 747188,245 741558,246 536875,247 764661,248 213125,249 616961,250 793108,251 423646,252 467976,253 605004,254 688467,255 49870,256 262479,257 832414,258 877876,259 461209,260 731035,261 64514,262 366609,263 124553,264 549323,265 913630,266 791920,267 317787,268 83302,269 648320,270 741735,271 432146,272 686747,273 212653,274 282490,275 834823,276 890898,277 507776,278 13451,279 81174,280 955034,281 896890,282 220128,283 37689,284 348414,285 997162,286 487560,287 131226,288 666594,289 975059,290 993665,291 214952,292 213648,293 340123,294 325228,295 681253,296 151021,297 601339,298 28349,299 385410,300 204223,301 77780,302 972883,303 723351,304 147720,305 881747,306 689841,307 740231,308 637843,309 818607,310 637859,311 341108,312 728862,313 149437,314 159931,315 615414,316 369034,317 66195,318 243563,319 242897,320 49263,321 871459,322 499220,323 395002,324 161901,325 116524,326 68018,327 915914,328 776144,329 348580,330 294871,331 902365,332 411124,333 424263,334 489384,335 159953,336 439093,337 365289,338 630836,339 92120,340 774424,341 931440,342 281,343 505843,344 194887,345 628302,346 484719,347 306239,348 851221,349 597166,350 257331,351 752384,352 932948,353 414972,354 815302,355 131550,356 802709,357 938625,358 994562,359 662446,360 14308,361 439702,362 713820,363 999078,364 322545,365 887099,366 697027,367 447072,368 890734,369 257122,370 413132,371 595686,372 654582,373 721425,374 567636,375 754702,376 826982,377 178469,378 114281,379 821758,380 81722,381 418025,382 910474,383 293303,384 394562,385 952301,386 128491,387 439518,388 991768,389 179865,390 633381,391 473527,392 187768,393 91199,394 696192,395 803116,396 402083,397 232596,398 9346,399 943351,400 242939,401 865854,402 529775,403 552719,404 229342,405 180149,406 363706,407 739936,408 714879,409 651372,410 693584,411 230081,412 751629,413 249682,414 80536,415 175732,416 902726,417 256609,418 690764,419 856348,420 965178,421 262269,422 483990,423 789842,424 743420,425 278582,426 212544,427 752730,428 435398,429 235603,430 256044,431 28746,432 965670,433 858517,434 78644,435 443885,436 57937,437 353416,438 202813,439 943379,440 32524,441 919842,442 351144,443 239497,444 667429,445 787241,446 706499,447 95572,448 482001,449 354725,450 192525,451 358206,452 34148,453 340086,454 537059,455 21563,456 364367,457 894938,458 257484,459 893910,460 471137,461 674040,462 680086,463 234651,464 604536,465 469575,466 294429,467 347220,468 424280,469 701664,470 66790,471 484577,472 262980,473 235058,474 750422,475 715952,476 628340,477 249165,478 971523,479 446688,480 882311,481 835588,482 490049,483 970829,484 131205,485 385949,486 791316,487 119140,488 568379,489 332522,490 689069,491 793833,492 247322,493 814825,494 300158,495 749967,496 51913,497 396145,498 171073,499 453646,500 751173,501 419103,502 321078,503 800877,504 376736,505 838276,506 76046,507 976147,508 253011,509 937309,510 948434,511 749974,512 525407,513 129652,514 33668,515 550870,516 130779,517 911791,518 759977,519 14211,520 921268,521 14953,522 945066,523 557919,524 145465,525 301818,526 794887,527 20171,528 639745,529 297938,530 720389,531 47060,532 457066,533 812433,534 959615,535 447690,536 988781,537 753824,538 402433,539 368188,540 419743,541 611842,542 799332,543 621088,544 23374,545 282914,546 33056,547 925198,548 683806,549 222945,550 350233,551 13883,552 502573,553 788396,554 365567,555 506739,556 286843,557 135154,558 349814,559 883985,560 294856,561 18262,562 518479,563 725124,564 257172,565 676788,566 821111,567 335962,568 857655,569 665421,570 566931,571 596311,572 566750,573 24747,574 132995,575 350148,576 73084,577 34788,578 205016,579 806491,580 108945,581 110213,582 806511,583 7929,584 133921,585 353193,586 688289,587 349128,588 378994,589 475754,590 837894,591 918635,592 561191,593 444441,594 291948,595 115610,596 38130,597 698313,598 193832,599 432501,600 488500,601 248,602 916722,603 795101,604 550845,605 705322,606 496102,607 733902,608 512604,609 704667,610 168048,611 256451,612 605370,613 511738,614 845182,615 37666,616 944285,617 325110,618 827886,619 355595,620 441850,621 1033,622 386943,623 716573,624 450702,625 404689,626 291575,627 820473,628 41884,629 855329,630 388210,631 482516,632 401597,633 802986,634 79990,635 147085,636 195972,637 385488,638 575092,639 907489,640 19061,641 678104,642 939934,643 749738,644 684148,645 51674,646 712222,647 72514,648 554444,649 460103,650 66046,651 888663,652 269589,653 965067,654 587459,655 648101,656 162635,657 628930,658 669649,659 22031,660 305662,661 279484,662 959343,663 653862,664 765465,665 625493,666 758559,667 933433,668 8,669 590655,670 885185,671 601413,672 913743,673 768525,674 117415,675 97246,676 988831,677 324125,678 277639,679 984919,680 132645,681 951471,682 529752,683 871263,684 34177,685 397961,686 755325,687 929897,688 409310,689 859713,690 607343,691 578006,692 242602,693 852361,694 280594,695 550872,696 382184,697 662435,698 87897,699 530121,700 610455,701 369757,702 776857,703 304296,704 82948,705 914410,706 851678,707 904054,708 248546,709 187897,710 856605,711 91497,712 391586,713 122888,714 629643,715 378565,716 852464,717 2597,718 508733,719 922009,720 328284,721 76696,722 957507,723 126228,724 667905,725 384149,726 294038,727 609230,728 181657,729 269982,730 785821,731 492861,732 8182,733 95180,734 219989,735 468852,736 675749,737 956950,738 18066,739 743532,740 690537,741 607275,742 597797,743 323514,744 232166,745 99020,746 751923,747 27986,748 904687,749 464082,750 208454,751 282835,752 13365,753 979311,754 856122,755 145910,756 758242,757 824814,758 697399,759 34771,760 567193,761 491971,762 388847,763 586091,764 573972,765 835514,766 195417,767 36996,768 215069,769 805760,770 905912,771 559664,772 680671,773 532821,774 704388,775 652505,776 772211,777 360888,778 647426,779 336566,780 727525,781 237104,782 693309,783 802493,784 183876,785 761439,786 667396,787 221543,788 928842,789 221458,790 622569,791 612239,792 309847,793 783539,794 250314,795 929371,796 891787,797 818579,798 264862,799 14104,800 415485,801 200072,802 585905,803 254046,804 919604,805 487338,806 546795,807 463297,808 970544,809 542842,810 843446,811 657891,812 553080,813 104852,814 191839,815 554074,816 272593,817 523349,818 797355,819 791774,820 769210,821 864037,822 731877,823 184210,824 75167,825 186514,826 624109,827 938905,828 102820,829 23104,830 875432,831 227819,832 897880,833 667801,834 559342,835 623425,836 68195,837 741525,838 648154,839 778004,840 750198,841 279914,842 216708,843 995970,844 860682,845 732230,846 156653,847 176718,848 730080,849 675152,850 586236,851 41148,852 805078,853 356167,854 18201,855 732631,856 90249,857 611598,858 243260,859 175051,860 320754,861 155108,862 673988,863 301629,864 240158,865 532401,866 557439,867 389344,868 19981,869 294142,870 651947,871 452326,872 903241,873 634454,874 371592,875 683126,876 314938,877 183367,878 848438,879 758929,880 168808,881 129574,882 335299,883 181505,884 314342,885 26095,886 125025,887 657806,888 126828,889 66928,890 791417,891 950256,892 653474,893 657155,894 783333,895 861991,896 56026,897 810731,898 374752,899 151283,900 661767,901 642135,902 800161,903 348214,904 124449,905 369620,906 52100,907 652455,908 633411,909 819727,910 881698,911 143786,912 519867,913 342143,914 99441,915 723203,916 613402,917 138119,918 2635,919 259942,920 301905,921 492799,922 856170,923 711956,924 696669,925 978811,926 43638,927 70967,928 518690,929 846866,930 544912,931 681930,932 156246,933 707058,934 621369,935 965081,936 57522,937 662283,938 214068,939 507172,940 873790,941 332284,942 640356,943 682979,944 116155,945 611683,946 240685,947 339965,948 753185,949 643962,950 169897,951 600792,952 557665,953 160310,954 843106,955 160570,956 676957,957 542067,958 56052,959 510407,960 2832,961 407719,962 448714,963 10392,964 316656,965 866875,966 775234,967 708030,968 532521,969 121173,970 349113,971 28274,972 706339,973 649898,974 111471,975 738889,976 723997,977 448121,978 332142,979 807719,980 951702,981 918558,982 785948,983 283235,984 752004,985 809416,986 223490,987 563563,988 916735,989 658193,990 503686,991 262743,992 234946,993 448340,994 167325,995 852082,996 958706,997 141214,998 378982,999 972006,1000 100609,1001 800411,1002 775020,1003 99149,1004 15807,1005 724684,1006 234910,1007 419100,1008 583356,1009 23204,1010 911638,1011 997522,1012 813660,1013 913622,1014 120369,1015 891548,1016 26370,1017 592509,1018 560498,1019 302590,1020 612231,1021 941828,1022 186546,1023 215470,1024 363868,1025 237978,1026 816966,1027 356798,1028 953508,1029 704117,1030 838724,1031 900951,1032 387206,1033 496341,1034 358526,1035 886167,1036 391456,1037 987595,1038 953186,1039 258533,1040 311929,1041 160901,1042 602839,1043 395810,1044 803261,1045 6570,1046 317530,1047 665150,1048 772527,1049 556719,1050 146696,1051 703857,1052 368904,1053 221398,1054 677755,1055 86410,1056 517010,1057 614273,1058 52320,1059 164402,1060 703727,1061 108010,1062 460210,1063 843045,1064 570783,1065 552348,1066 942769,1067 843968,1068 869914,1069 232391,1070 821018,1071 800402,1072 156700,1073 36148,1074 449837,1075 472014,1076 20937,1077 42281,1078 495820,1079 498331,1080 926406,1081 293240,1082 788027,1083 632595,1084 998657,1085 959744,1086 415722,1087 453312,1088 106488,1089 222593,1090 870249,1091 406272,1092 294889,1093 932959,1094 634765,1095 1090,1096 295609,1097 349952,1098 324236,1099 573598,1100 29639,1101 46093,1102 687869,1103 598399,1104 923556,1105 785381,1106 856034,1107 218698,1108 863317,1109 689348,1110 804541,1111 467363,1112 649757,1113 395918,1114 471348,1115 773833,1116 922561,1117 168294,1118 738167,1119 322246,1120 10361,1121 235611,1122 22770,1123 53324,1124 803305,1125 92985,1126 757273,1127 679690,1128 161695,1129 331727,1130 665166,1131 268441,1132 478508,1133 435828,1134 789904,1135 8879,1136 46070,1137 829285,1138 902520,1139 698897,1140 267551,1141 455101,1142 560160,1143 725128,1144 367709,1145 577514,1146 895660,1147 207489,1148 61349,1149 970414,1150 893663,1151 782554,1152 632648,1153 183868,1154 973756,1155 95859,1156 709234,1157 360534,1158 591167,1159 138405,1160 992178,1161 86538,1162 206193,1163 14291,1164 415211,1165 393256,1166 20181,1167 866433,1168 253518,1169 924603,1170 898706,1171 826668,1172 491040,1173 537967,1174 173562,1175 868691,1176 150839,1177 886867,1178 886744,1179 162514,1180 872522,1181 988867,1182 2146,1183 800990,1184 769651,1185 15453,1186 117602,1187 277158,1188 261268,1189 902066,1190 407556,1191 376353,1192 943389,1193 638742,1194 230000,1195 492801,1196 872964,1197 992939,1198 532676,1199 710097,1200 881765,