TheRealSamuel/LeetCodeProblem
0572
1{2 "id": 3443,3 "name": "maximum_total_reward_using_operations_ii",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-ii/",6 "date": "2024-06-02 00:00:00",7 "task_description": "You are given an integer array `rewardValues` of length `n`, representing the values of rewards. Initially, your total reward `x` is 0, and all indices are **unmarked**. You are allowed to perform the following operation **any** number of times: Choose an **unmarked** index `i` from the range `[0, n - 1]`. If `rewardValues[i]` is **greater** than your current total reward `x`, then add `rewardValues[i]` to `x` (i.e., `x = x + rewardValues[i]`), and **mark** the index `i`. Return an integer denoting the **maximum **_total reward_ you can collect by performing the operations optimally. **Example 1:** **Input:** rewardValues = [1,1,3,3] **Output:** 4 **Explanation:** During the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum. **Example 2:** **Input:** rewardValues = [1,6,4,3,2] **Output:** 11 **Explanation:** Mark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum. **Constraints:** `1 <= rewardValues.length <= 5 * 104` `1 <= rewardValues[i] <= 5 * 104`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "rewardValues = [1,1,3,3]",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "rewardValues = [1,6,4,3,2]",17 "output": "11 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 19751,24 1936,25 30090,26 30814,27 22116,28 1913,29 596,30 37030,31 33285,32 28724,33 16151,34 28169,35 33318,36 41004,37 38998,38 26918,39 40268,40 9720,41 47723,42 44816,43 39048,44 17981,45 9659,46 11378,47 16297,48 3616,49 40312,50 33199,51 32253,52 4517,53 42649,54 45271,55 26135,56 37915,57 37591,58 22925,59 1340,60 32947,61 22906,62 17476,63 8119,64 6150,65 35436,66 18090,67 39514,68 14588,69 31273,70 2266,71 36757,72 5135,73 3868,74 269,75 28189,76 38868,77 38882,78 46910,79 16825,80 44337,81 17411,82 49068,83 12189,84 15672,85 32659,86 35870,87 25688,88 42730,89 38811,90 15567,91 5266,92 42108,93 24706,94 15345,95 40462,96 29646,97 31208,98 22915,99 20829,100 28721,101 1568,102 13717,103 16446,104 28774,105 12257,106 11103,107 10705,108 46422,109 31486,110 46096,111 4032,112 13957,113 3928,114 6721,115 38956,116 21296,117 34278,118 37333,119 11639,120 36152,121 43716,122 34450,123 6363,124 16535,125 40177,126 44334,127 42362,128 22888,129 27244,130 4272,131 28657,132 36654,133 30238,134 25016,135 11555,136 38928,137 7824,138 8690,139 47093,140 36807,141 12261,142 7358,143 30720,144 16551,145 44385,146 3439,147 43232,148 41821,149 19583,150 39844,151 37264,152 41760,153 8024,154 32360,155 4219,156 4299,157 22135,158 32706,159 225,160 25511,161 9929,162 20118,163 28945,164 46182,165 44541,166 31957,167 44124,168 2805,169 27293,170 18957,171 28859,172 48678,173 10394,174 12113,175 547,176 6022,177 46639,178 47101,179 31735,180 41773,181 14375,182 16429,183 9298,184 820,185 30812,186 37271,187 37648,188 44956,189 21712,190 38490,191 42494,192 33413,193 28972,194 47174,195 34227,196 31765,197 45060,198 4476,199 24648,200 15147,201 2236,202 40376,203 32330,204 21010,205 48861,206 14891,207 45101,208 40388,209 32023,210 47800,211 22013,212 7040,213 49326,214 35129,215 40853,216 27625,217 33065,218 35797,219 5425,220 7056,221 39226,222 14237,223 30320,224 49445,225 45987,226 13824,227 18314,228 49195,229 696,230 27130,231 44825,232 7534,233 39348,234 21569,235 43974,236 10541,237 46575,238 7957,239 37847,240 26081,241 22557,242 9898,243 15525,244 3759,245 33879,246 5046,247 1721,248 44751,249 1046,250 32450,251 28717,252 31189,253 24253,254 28196,255 27435,256 22870,257 9243,258 39276,259 24540,260 31133,261 8193,262 3065,263 18654,264 9507,265 25128,266 35584,267 46865,268 48374,269 10003,270 15765,271 14893,272 17867,273 15379,274 44771,275 27309,276 5046,277 510,278 33839,279 39485,280 9817,281 3281,282 16103,283 24163,284 42854,285 23199,286 41945,287 2066,288 32535,289 3562,290 9793,291 15353,292 28605,293 12608,294 43610,295 14577,296 36285,297 48173,298 43878,299 34811,300 30893,301 25225,302 17159,303 9590,304 9577,305 18898,306 4254,307 31040,308 23367,309 6306,310 4462,311 41232,312 11705,313 21721,314 39085,315 25343,316 37947,317 38876,318 23291,319 42207,320 4215,321 5689,322 24233,323 27706,324 21842,325 46191,326 26262,327 3814,328 14583,329 25905,330 44688,331 12036,332 35813,333 48274,334 11610,335 3729,336 1104,337 46017,338 42331,339 38632,340 27453,341 34560,342 45415,343 5428,344 49861,345 21388,346 23531,347 41389,348 14489,349 8669,350 22851,351 4479,352 8356,353 11649,354 22067,355 19491,356 16510,357 36127,358 42194,359 47012,360 8299,361 26410,362 39668,363 18772,364 15069,365 4205,366 26501,367 4963,368 26078,369 35939,370 48719,371 19688,372 23654,373 12876,374 41335,375 34235,376 22361,377 7007,378 895,379 21321,380 36392,381 32733,382 49874,383 13064,384 4183,385 43592,386 22,387 39160,388 38685,389 42227,390 38254,391 8452,392 39141,393 4613,394 11515,395 9922,396 44285,397 11741,398 36857,399 21675,400 265,401 20120,402 48636,403 31802,404 9148,405 14399,406 42686,407 7827,408 10010,409 38167,410 25802,411 39028,412 44787,413 8559,414 47343,415 37801,416 1406,417 29334,418 39141,419 21793,420 37649,421 30003,422 11820,423 45283,424 29761,425 29538,426 1915,427 19742,428 45346,429 22522,430 12328,431 34318,432 10108,433 29472,434 32337,435 19275,436 33569,437 3302,438 8896,439 46068,440 23870,441 45602,442 35686,443 12410,444 8206,445 25153,446 22802,447 13845,448 40348,449 45685,450 44231,451 5316,452 16611,453 11713,454 39617,455 4446,456 18666,457 42063,458 37622,459 33198,460 19876,461 22911,462 35142,463 27288,464 8116,465 667,466 2365,467 33197,468 18059,469 31111,470 18035,471 37307,472 37622,473 3991,474 47741,475 27405,476 24121,477 47391,478 26610,479 34079,480 24562,481 7721,482 4400,483 17124,484 19072,485 3352,486 28946,487 38242,488 39836,489 12042,490 27819,491 49488,492 3002,493 40607,494 21531,495 1215,496 44909,497 6140,498 14403,499 14324,500 5443,501 3170,502 27162,503 34239,504 29974,505 45498,506 36666,507 42015,508 43334,509 31270,510 16258,511 39487,512 44270,513 5879,514 47614,515 25071,516 27809,517 37811,518 8093,519 22218,520 19820,521 18534,522 33029,523 21091,524 33481,525 21258,526 7628,527 27712,528 18767,529 44912,530 44889,531 16366,532 47685,533 3771,534 33257,535 37751,536 40725,537 10997,538 24021,539 36042,540 21072,541 39005,542 26530,543 40214,544 23772,545 4485,546 18258,547 13697,548 41677,549 33172,550 2159,551 17061,552 31308,553 40832,554 32520,555 25660,556 45132,557 14493,558 47870,559 45168,560 47638,561 29689,562 41390,563 10191,564 26644,565 35536,566 89,567 273,568 3383,569 33561,570 8122,571 2145,572 5188,573 19330,574 45964,575 35442,576 47279,577 21257,578 49840,579 45392,580 39571,581 12654,582 40922,583 23229,584 8023,585 43649,586 39983,587 19556,588 30875,589 6770,590 17511,591 22546,592 34988,593 41407,594 40270,595 13435,596 35072,597 15888,598 10573,599 37616,600 22012,601 34108,602 23607,603 42807,604 9677,605 30993,606 31534,607 17299,608 26153,609 26676,610 15338,611 18759,612 22395,613 17741,614 10957,615 9705,616 38732,617 46787,618 7436,619 37666,620 37552,621 34726,622 49889,623 1261,624 37989,625 22841,626 16811,627 28421,628 16463,629 14722,630 33038,631 18269,632 47201,633 19640,634 35599,635 31453,636 28594,637 6452,638 16567,639 1135,640 6629,641 22013,642 3495,643 6749,644 10880,645 41464,646 10039,647 42754,648 5615,649 32690,650 31950,651 1887,652 3071,653 26865,654 6764,655 38046,656 21957,657 10722,658 31514,659 47406,660 7531,661 33703,662 20900,663 407,664 40862,665 26759,666 11640,667 8487,668 10065,669 14426,670 47998,671 33277,672 26811,673 44930,674 45195,675 33685,676 16088,677 48326,678 15888,679 40092,680 2787,681 21500,682 38714,683 39569,684 18540,685 8921,686 34206,687 28912,688 21931,689 4295,690 30419,691 11049,692 29044,693 6996,694 23221,695 11219,696 35953,697 42586,698 5678,699 23631,700 37637,701 13236,702 27258,703 45345,704 32151,705 28119,706 20413,707 693,708 39086,709 22323,710 4969,711 33547,712 44149,713 14725,714 43693,715 45880,716 16272,717 35349,718 43572,719 29270,720 30308,721 43006,722 16372,723 3532,724 14095,725 32681,726 7822,727 37624,728 23526,729 20144,730 19169,731 23440,732 31095,733 31184,734 23200,735 48715,736 7577,737 33363,738 44956,739 14027,740 42594,741 14475,742 3666,743 13968,744 17457,745 49348,746 15201,747 21495,748 2087,749 35476,750 5256,751 30119,752 13386,753 26769,754 23668,755 42840,756 9024,757 10551,758 7056,759 13928,760 25247,761 17817,762 7957,763 35618,764 23962,765 2267,766 2793,767 1105,768 1334,769 3521,770 49376,771 40241,772 29321,773 32351,774 11549,775 28987,776 10481,777 42637,778 20752,779 12564,780 9758,781 10460,782 21102,783 14751,784 28088,785 32842,786 13031,787 8278,788 816,789 5685,790 23459,791 30643,792 49256,793 49834,794 49835,795 46243,796 5198,797 7674,798 2107,799 41235,800 2199,801 11401,802 26425,803 10104,804 36504,805 39554,806 7350,807 37055,808 15106,809 20014,810 33796,811 27777,812 10136,813 49878,814 16998,815 16183,816 6861,817 11946,818 47102,819 39806,820 46273,821 4962,822 45869,823 46564,824 8123,825 27817,826 10148,827 27769,828 40719,829 48206,830 29933,831 38628,832 48292,833 8980,834 37661,835 9697,836 47514,837 33022,838 22183,839 32745,840 10545,841 22795,842 46714,843 43067,844 7533,845 24160,846 20499,847 32614,848 629,849 49547,850 4613,851 42702,852 44601,853 26456,854 29887,855 40064,856 47293,857 8431,858 13263,859 48374,860 40742,861 48581,862 15364,863 19310,864 47629,865 35361,866 35904,867 42842,868 9777,869 8586,870 32165,871 42371,872 1657,873 41226,874 23548,875 46866,876 14187,877 36999,878 31392,879 7122,880 47896,881 8013,882 9950,883 3098,884 44267,885 18743,886 19383,887 38518,888 9703,889 30261,890 24182,891 37823,892 20902,893 30187,894 48856,895 44060,896 39637,897 33246,898 44461,899 4041,900 14215,901 15376,902 27867,903 14085,904 102,905 4910,906 25229,907 22949,908 32385,909 6904,910 45060,911 43975,912 15859,913 48396,914 37882,915 9296,916 10856,917 12729,918 4712,919 25753,920 48518,921 20774,922 7998,923 610,924 25696,925 46164,926 43713,927 21263,928 13727,929 18322,930 33608,931 33113,932 15694,933 23709,934 42886,935 15201,936 11088,937 40864,938 6342,939 31645,940 1496,941 45085,942 40338,943 29428,944 12284,945 1630,946 45280,947 13457,948 15227,949 15352,950 28042,951 44538,952 13881,953 12930,954 36789,955 26110,956 13188,957 3278,958 46735,959 19480,960 15065,961 41384,962 16054,963 23992,964 43648,965 10432,966 23704,967 46769,968 17467,969 13321,970 43270,971 28539,972 6087,973 35269,974 30894,975 9263,976 3243,977 16156,978 35805,979 7781,980 37462,981 33427,982 18846,983 38978,984 19585,985 4312,986 28759,987 49616,988 8192,989 12138,990 49087,991 38253,992 19514,993 279,994 17987,995 49993,996 40241,997 36882,998 30314,999 25790,1000 4636,1001 16589,1002 47027,1003 10352,1004 23144,1005 35720,1006 13340,1007 7870,1008 33778,1009 8814,1010 20737,1011 33823,1012 31089,1013 23603,1014 23559,1015 34108,1016 9716,1017 18593,1018 40954,1019 5293,1020 16049,1021 17933,1022 38125,1023 17784,1024 6827,1025 766,1026 28954,1027 41150,1028 2606,1029 24352,1030 47254,1031 39903,1032 39988,1033 4365,1034 13451,1035 14021,1036 49098,1037 12831,1038 329,1039 31943,1040 19151,1041 21046,1042 2276,1043 46821,1044 25259,1045 29925,1046 17374,1047 49,1048 25083,1049 47676,1050 37737,1051 11055,1052 14706,1053 36724,1054 34300,1055 10141,1056 27449,1057 12539,1058 45486,1059 30471,1060 17651,1061 7827,1062 8235,1063 17579,1064 21302,1065 24558,1066 44183,1067 3969,1068 34390,1069 29355,1070 41385,1071 43560,1072 11957,1073 7744,1074 27726,1075 32058,1076 19908,1077 10349,1078 4295,1079 44957,1080 48512,1081 35579,1082 1372,1083 48175,1084 44673,1085 41265,1086 32309,1087 16836,1088 47319,1089 41799,1090 34967,1091 9079,1092 4870,1093 46424,1094 20215,1095 27346,1096 25470,1097 22304,1098 20525,1099 2617,1100 16572,1101 37241,1102 23130,1103 47941,1104 38316,1105 15866,1106 4069,1107 1497,1108 36360,1109 35777,1110 38836,1111 19328,1112 535,1113 38767,1114 40782,1115 48940,1116 10369,1117 27114,1118 31360,1119 34257,1120 36619,1121 42423,1122 25271,1123 8210,1124 47511,1125 17209,1126 43497,1127 32279,1128 32960,1129 30891,1130 33001,1131 42425,1132 47935,1133 5477,1134 37519,1135 27080,1136 17673,1137 20868,1138 44579,1139 2047,1140 7410,1141 4653,1142 16973,1143 27433,1144 36389,1145 9850,1146 12249,1147 12419,1148 40529,1149 40831,1150 6903,1151 42429,1152 23364,1153 36826,1154 11765,1155 15057,1156 44136,1157 46642,1158 16359,1159 13624,1160 2145,1161 5562,1162 27941,1163 8919,1164 42571,1165 31387,1166 2134,1167 9600,1168 41744,1169 4139,1170 35087,1171 1493,1172 39852,1173 23704,1174 16712,1175 13432,1176 42897,1177 9840,1178 47059,1179 8998,1180 48630,1181 15318,1182 39716,1183 34985,1184 38377,1185 30284,1186 35324,1187 40188,1188 10289,1189 44707,1190 32127,1191 5284,1192 4645,1193 21908,1194 32361,1195 31131,1196 6427,1197 30938,1198 16180,1199 48808,1200 46062,