FPEvalDataset/LeetCodeProblem
0302
1{2 "id": 3776,3 "name": "find_minimum_cost_to_remove_array_elements",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/find-minimum-cost-to-remove-array-elements/",6 "date": "2025-02-15 00:00:00",7 "task_description": "You are given an integer array `nums`. Your task is to remove **all elements** from the array by performing one of the following operations at each step until `nums` is empty: Choose any two elements from the first three elements of `nums` and remove them. The cost of this operation is the **maximum** of the two elements removed. If fewer than three elements remain in `nums`, remove all the remaining elements in a single operation. The cost of this operation is the **maximum** of the remaining elements. Return the **minimum** cost required to remove all the elements. **Example 1:** **Input:** nums = [6,2,8,4] **Output:** 12 **Explanation:** Initially, `nums = [6, 2, 8, 4]`. In the first operation, remove `nums[0] = 6` and `nums[2] = 8` with a cost of `max(6, 8) = 8`. Now, `nums = [2, 4]`. In the second operation, remove the remaining elements with a cost of `max(2, 4) = 4`. The cost to remove all elements is `8 + 4 = 12`. This is the minimum cost to remove all elements in `nums`. Hence, the output is 12. **Example 2:** **Input:** nums = [2,1,3,3] **Output:** 5 **Explanation:** Initially, `nums = [2, 1, 3, 3]`. In the first operation, remove `nums[0] = 2` and `nums[1] = 1` with a cost of `max(2, 1) = 2`. Now, `nums = [3, 3]`. In the second operation remove the remaining elements with a cost of `max(3, 3) = 3`. The cost to remove all elements is `2 + 3 = 5`. This is the minimum cost to remove all elements in `nums`. Hence, the output is 5. **Constraints:** `1 <= nums.length <= 1000` `1 <= nums[i] <= 106`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [6,2,8,4]",12 "output": "12 "13 },14 {15 "label": "Example 2",16 "input": "nums = [2,1,3,3]",17 "output": "5 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 558184,24 699123,25 665132,26 129561,27 465407,28 188054,29 571296,30 264707,31 895833,32 530870,33 188408,34 205446,35 319070,36 199047,37 419054,38 224993,39 732862,40 802389,41 249067,42 354625,43 970628,44 365878,45 7109,46 48467,47 858084,48 539210,49 638358,50 27606,51 421865,52 943755,53 980282,54 345015,55 22560,56 78319,57 979907,58 632714,59 755924,60 10697,61 800884,62 599917,63 416179,64 613199,65 3403,66 630936,67 628709,68 324079,69 814551,70 881211,71 793162,72 293147,73 919295,74 154547,75 905031,76 301250,77 717863,78 332602,79 128753,80 759888,81 346784,82 466566,83 450840,84 601038,85 286109,86 680932,87 256053,88 207170,89 37699,90 385549,91 383259,92 808981,93 92517,94 539289,95 905576,96 234027,97 986272,98 692043,99 554934,100 252177,101 76671,102 720380,103 932735,104 745575,105 83342,106 5358,107 565133,108 862132,109 803964,110 61353,111 846562,112 726131,113 787373,114 56704,115 51873,116 817001,117 87544,118 724422,119 699922,120 225252,121 359123,122 98806,123 13051,124 432439,125 437280,126 116033,127 70668,128 141944,129 298291,130 681786,131 231110,132 687067,133 688255,134 490572,135 735426,136 498004,137 1967,138 135664,139 917912,140 738288,141 983084,142 575691,143 59921,144 590309,145 782815,146 444956,147 903003,148 902780,149 474769,150 232239,151 935954,152 234252,153 688519,154 120525,155 8794,156 706,157 997077,158 939190,159 971377,160 755071,161 232032,162 624065,163 28501,164 554964,165 122313,166 713846,167 427260,168 679933,169 197484,170 767171,171 289322,172 961272,173 185375,174 47439,175 14070,176 691915,177 754049,178 663676,179 446481,180 950193,181 959764,182 879516,183 8672,184 665535,185 248378,186 327201,187 904041,188 103607,189 437684,190 991294,191 167938,192 510605,193 907425,194 750010,195 673710,196 91315,197 872537,198 246912,199 919597,200 512366,201 501926,202 502535,203 856743,204 810310,205 905227,206 786461,207 812380,208 314138,209 926264,210 263089,211 653807,212 39039,213 492391,214 343559,215 855992,216 637439,217 232705,218 747613,219 82965,220 474052,221 529105,222 736903,223 668425,224 593965,225 813734,226 545209,227 697750,228 818314,229 519786,230 992912,231 511260,232 286710,233 594029,234 66202,235 713602,236 563843,237 100284,238 54333,239 955660,240 268746,241 148621,242 673760,243 670543,244 861442,245 540994,246 180245,247 991469,248 225692,249 173225,250 659315,251 792744,252 777415,253 85418,254 217991,255 310974,256 105987,257 317451,258 222000,259 929482,260 319008,261 546919,262 565583,263 514628,264 377355,265 916072,266 265724,267 729730,268 725495,269 824406,270 301464,271 856757,272 857206,273 516337,274 753790,275 354521,276 177227,277 437224,278 688378,279 477480,280 323871,281 751705,282 469058,283 712841,284 279418,285 98553,286 635639,287 889339,288 585094,289 11584,290 992206,291 963107,292 344486,293 152960,294 150106,295 623110,296 536372,297 423803,298 997099,299 778744,300 976991,301 768142,302 357600,303 46234,304 983519,305 775588,306 255356,307 105498,308 993947,309 813909,310 869515,311 267122,312 749997,313 417449,314 533813,315 474503,316 7112,317 590373,318 573166,319 31733,320 213535,321 430296,322 642846,323 3522,324 813534,325 306197,326 188128,327 758095,328 429582,329 993315,330 224643,331 146526,332 702186,333 735688,334 793844,335 958499,336 889872,337 356152,338 652026,339 333238,340 468821,341 454089,342 20647,343 270543,344 810124,345 697667,346 346952,347 537437,348 376436,349 191684,350 627414,351 208513,352 149618,353 866692,354 616377,355 935062,356 291701,357 574715,358 786857,359 8796,360 176548,361 507287,362 296095,363 254634,364 864032,365 265026,366 353666,367 966868,368 561185,369 102895,370 952437,371 871799,372 890954,373 889673,374 865461,375 882147,376 435970,377 178279,378 176319,379 263371,380 756000,381 119048,382 278044,383 616157,384 266295,385 20447,386 639965,387 277510,388 871251,389 747843,390 12289,391 474241,392 260770,393 440143,394 379234,395 123540,396 646358,397 525688,398 749639,399 451815,400 569374,401 468095,402 352106,403 991613,404 340520,405 97905,406 89205,407 101035,408 297067,409 732913,410 860523,411 424243,412 26639,413 262943,414 798401,415 443802,416 486862,417 548100,418 567958,419 602381,420 776136,421 869217,422 989386,423 460465,424 925823,425 439424,426 452544,427 455462,428 343151,429 951815,430 579795,431 907003,432 990819,433 230599,434 402039,435 746617,436 498584,437 524681,438 842501,439 8630,440 120653,441 474200,442 233334,443 676089,444 580569,445 426682,446 550875,447 427086,448 672437,449 480799,450 711646,451 698582,452 167610,453 401358,454 792479,455 141461,456 834079,457 918522,458 813772,459 169015,460 249077,461 620467,462 294778,463 134456,464 521777,465 866261,466 635692,467 545897,468 954533,469 668106,470 854540,471 570264,472 420245,473 85769,474 242042,475 521560,476 530041,477 613842,478 943436,479 469512,480 737360,481 740041,482 415399,483 357320,484 450202,485 895811,486 616927,487 548786,488 22669,489 629584,490 264598,491 984851,492 601669,493 67259,494 731927,495 528809,496 178238,497 906391,498 308398,499 964520,500 522481,501 251275,502 842619,503 835213,504 146739,505 106861,506 357703,507 583231,508 736742,509 552163,510 96020,511 100008,512 835185,513 661292,514 541741,515 82451,516 915263,517 950862,518 231381,519 415885,520 107948,521 387024,522 816830,523 843789,524 766932,525 300556,526 967229,527 961457,528 899409,529 596662,530 759485,531 707658,532 77963,533 627412,534 353050,535 51827,536 309683,537 209049,538 9532,539 886873,540 623875,541 557185,542 641276,543 147458,544 777920,545 46281,546 524037,547 291821,548 621972,549 766805,550 417480,551 919106,552 639564,553 427886,554 920687,555 994537,556 510100,557 574858,558 951699,559 276197,560 618440,561 202063,562 787035,563 497768,564 539532,565 557790,566 439911,567 495344,568 207142,569 211397,570 883944,571 973974,572 927601,573 664255,574 216749,575 932257,576 996983,577 414405,578 300946,579 994083,580 306295,581 537337,582 900842,583 724242,584 671062,585 276033,586 525947,587 192010,588 143554,589 80706,590 802827,591 831978,592 841260,593 305035,594 200048,595 201067,596 302208,597 113783,598 399449,599 914357,600 551630,601 360994,602 315846,603 501673,604 622572,605 717400,606 76851,607 673297,608 528264,609 830641,610 391605,611 428391,612 94442,613 651708,614 57336,615 738280,616 309575,617 329855,618 555373,619 318206,620 111124,621 76256,622 991418623 ],624 "output": 168636285625 },626 {627 "input": [628 554105,629 693833,630 595447,631 824409,632 166238,633 209598,634 371235,635 462579,636 308503,637 841809,638 314170,639 601108,640 556194,641 239049,642 834063,643 332403,644 418167,645 286919,646 594226,647 880857,648 655902,649 91952,650 108093,651 941712,652 376977,653 782354,654 750808,655 337606,656 60173,657 530259,658 71711,659 721396,660 405812,661 957974,662 681454,663 282942,664 26209,665 59,666 633460,667 721875,668 602217,669 698966,670 882718,671 765418,672 337707,673 107835,674 608257,675 821095,676 520788,677 758637,678 370919,679 227809,680 242105,681 363064,682 415151,683 546170,684 247101,685 981987,686 518859,687 795343,688 423449,689 413529,690 34345,691 756024,692 849567,693 788195,694 826722,695 636041,696 582078,697 625218,698 36753,699 115807,700 621707,701 541581,702 609093,703 975507,704 241854,705 910051,706 764706,707 676236,708 723565,709 338634,710 239502,711 38939,712 534258,713 305765,714 293694,715 330160,716 655484,717 866067,718 991948,719 326663,720 246025,721 768912,722 411011,723 397303,724 400643,725 93924,726 13304,727 817932,728 153192,729 860476,730 473848,731 233720,732 34806,733 117898,734 121730,735 461033,736 544057,737 446577,738 652503,739 800089,740 847541,741 221959,742 69576,743 33137,744 868664,745 585274,746 274323,747 291367,748 196182,749 138487,750 509170,751 805694,752 727804,753 753524,754 155990,755 307289,756 868052,757 11605,758 563382,759 136726,760 495717,761 744198,762 315014,763 497319,764 809508,765 353946,766 219777,767 479925,768 516454,769 143364,770 429542,771 773456,772 25885,773 716947,774 524334,775 11575,776 439640,777 97436,778 639087,779 127764,780 236810,781 475610,782 841241,783 949245,784 466775,785 778555,786 577858,787 347316,788 151306,789 984888,790 954621,791 125840,792 82190,793 532815,794 805080,795 851183,796 359568,797 69684,798 818383,799 10409,800 664656,801 114477,802 174801803 ],804 "output": 45503018805 },806 {807 "input": [808 166979,809 924662,810 155077,811 454041,812 146035,813 126430,814 493423,815 24272,816 884228,817 114187,818 222946,819 688852,820 318388,821 772357,822 669085,823 440208,824 150024,825 155332,826 274741,827 645829,828 466680,829 303311,830 410975,831 869855,832 267410,833 339329,834 803736,835 401215,836 738503,837 669783,838 924995,839 470880,840 188872,841 196611,842 265861,843 940839,844 629450,845 512891,846 622976,847 747851,848 191607,849 872361,850 959021,851 22017,852 813276,853 669573,854 405226,855 717256,856 766798,857 966444,858 475796,859 949912,860 818801,861 431100,862 563389,863 683591,864 691033,865 22470,866 385225,867 671361,868 555173,869 168908,870 325157,871 837492,872 342952,873 750289,874 423215,875 489581,876 194549,877 385411,878 593487,879 162649,880 935560,881 83315,882 94362,883 876890,884 915692,885 229249,886 556738,887 866368,888 236746,889 759009,890 361543,891 700065,892 408086,893 130468,894 604809,895 741584,896 597574,897 290633,898 557636,899 190009,900 723718,901 244344,902 910615,903 579415,904 729015,905 996705,906 385242,907 580014,908 778715,909 906929,910 642213,911 648196,912 101816,913 33960,914 828751,915 853949,916 647352,917 480044,918 291668,919 633581,920 613218,921 25024,922 3863,923 404553,924 794749,925 110250,926 437345,927 920807,928 588876,929 827114,930 208070,931 960810,932 937275,933 959833,934 645702,935 557198,936 298239,937 635510,938 996065,939 193429,940 738478,941 393262,942 805212,943 239792,944 821901,945 450115,946 337614,947 398863,948 668717,949 791957,950 24056,951 929596,952 458860,953 451583,954 878300,955 458223,956 872802,957 733487,958 221568,959 855260,960 208591,961 83368,962 108822,963 954754,964 752076,965 316203,966 279980,967 210250,968 688795,969 221197,970 955283,971 142914,972 704714,973 539790,974 210365,975 371886,976 246294,977 653194,978 358172,979 314878,980 801370,981 902627,982 669305,983 786322,984 545287,985 460154,986 576772,987 929269,988 50703,989 830066,990 174756,991 668937,992 533323,993 278946,994 720057,995 95260,996 14834,997 810133,998 872218,999 831923,1000 770832,1001 74270,1002 204916,1003 154628,1004 716205,1005 682797,1006 129985,1007 414049,1008 523846,1009 514197,1010 409170,1011 558477,1012 87068,1013 159128,1014 527255,1015 544768,1016 777387,1017 190083,1018 107313,1019 253027,1020 223208,1021 814475,1022 278932,1023 383041,1024 944869,1025 705495,1026 742025,1027 503152,1028 651901,1029 507678,1030 44983,1031 778497,1032 15617,1033 54097,1034 456916,1035 229008,1036 625200,1037 122747,1038 124320,1039 555,1040 649632,1041 529407,1042 828734,1043 382062,1044 85636,1045 655722,1046 343060,1047 362064,1048 386634,1049 423029,1050 927103,1051 68627,1052 786971,1053 328720,1054 258055,1055 628468,1056 682581,1057 978465,1058 403438,1059 457950,1060 333005,1061 796597,1062 901564,1063 188475,1064 915892,1065 63147,1066 421167,1067 435274,1068 861333,1069 486890,1070 725125,1071 22029,1072 720061,1073 464539,1074 980828,1075 689741,1076 131211,1077 385545,1078 806140,1079 488380,1080 401288,1081 809301,1082 720397,1083 357862,1084 561394,1085 732648,1086 605622,1087 640785,1088 317638,1089 533499,1090 751771,1091 661135,1092 249210,1093 291043,1094 546499,1095 81994,1096 670338,1097 664705,1098 151117,1099 527618,1100 298639,1101 732661,1102 186890,1103 428495,1104 445404,1105 726556,1106 785849,1107 443393,1108 598837,1109 365068,1110 320167,1111 789151,1112 149139,1113 60260,1114 958517,1115 34894,1116 854877,1117 324552,1118 774505,1119 275372,1120 602517,1121 51641,1122 325846,1123 90478,1124 467906,1125 55572,1126 994359,1127 301386,1128 459515,1129 355700,1130 292327,1131 592878,1132 120820,1133 987167,1134 274510,1135 310946,1136 677700,1137 979271,1138 723059,1139 725415,1140 132686,1141 550026,1142 793333,1143 681066,1144 530853,1145 761580,1146 819323,1147 628608,1148 831776,1149 868365,1150 159303,1151 729095,1152 385017,1153 750798,1154 373124,1155 506494,1156 574909,1157 208792,1158 399616,1159 576570,1160 180832,1161 391099,1162 247819,1163 985731,1164 76579,1165 231640,1166 169494,1167 62334,1168 235821,1169 763519,1170 46668,1171 373286,1172 71341,1173 640015,1174 272942,1175 137284,1176 501872,1177 704349,1178 267817,1179 935543,1180 714737,1181 231764,1182 535484,1183 265016,1184 852579,1185 89231,1186 661320,1187 685567,1188 658512,1189 294282,1190 65599,1191 736159,1192 253982,1193 978277,1194 547344,1195 690883,1196 537318,1197 506651,1198 327326,1199 625950,1200 574751,