CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes304downloads
1{2    "id": 2893,3    "name": "visit_array_positions_to_maximize_score",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/visit-array-positions-to-maximize-score/",6    "date": "1688774400000",7    "task_description": "You are given a **0-indexed** integer array `nums` and a positive integer `x`. You are **initially** at position `0` in the array and you can visit other positions according to the following rules: If you are currently in position `i`, then you can move to **any** position `j` such that `i < j`. For each position `i` that you visit, you get a score of `nums[i]`. If you move from a position `i` to a position `j` and the **parities** of `nums[i]` and `nums[j]` differ, then you lose a score of `x`. Return _the **maximum** total score you can get_. **Note** that initially you have `nums[0]` points. **Example 1:** ``` **Input:** nums = [2,3,6,1,9,2], x = 5 **Output:** 13 **Explanation:** We can visit the following positions in the array: 0 -> 2 -> 3 -> 4. The corresponding values are 2, 6, 1 and 9. Since the integers 6 and 1 have different parities, the move 2 -> 3 will make you lose a score of x = 5. The total score will be: 2 + 6 + 1 + 9 - 5 = 13. ``` **Example 2:** ``` **Input:** nums = [2,4,6,8], x = 3 **Output:** 20 **Explanation:** All the integers in the array have the same parities, so we can visit all of them without losing any score. The total score is: 2 + 4 + 6 + 8 = 20. ``` **Constraints:** `2 <= nums.length <= 105` `1 <= nums[i], x <= 106`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [2,3,6,1,9,2], x = 5",12            "output": "13 "13        },14        {15            "label": "Example 2",16            "input": "nums = [2,4,6,8], x = 3",17            "output": "20 "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                [24                    485218,25                    309709,26                    630635,27                    337575,28                    471891,29                    609441,30                    615815,31                    700447,32                    85332,33                    519324,34                    528124,35                    561172,36                    823184,37                    309613,38                    247626,39                    531839,40                    398557,41                    283267,42                    361606,43                    917018,44                    709132,45                    991857,46                    104164,47                    122268,48                    896020,49                    318965,50                    216425,51                    363123,52                    840228,53                    806757,54                    88360,55                    81391,56                    741015,57                    968506,58                    903142,59                    14202,60                    85318,61                    995900,62                    558618,63                    490698,64                    880065,65                    457288,66                    39493,67                    884068,68                    907319,69                    728076,70                    451136,71                    143959,72                    540174,73                    991389,74                    955279,75                    274109,76                    530754,77                    427419,78                    101773,79                    448682,80                    910600,81                    810696,82                    691453,83                    472803,84                    523554,85                    232254,86                    438324,87                    993193,88                    239326,89                    692257,90                    568214,91                    582839,92                    902547,93                    243549,94                    97729895                ],96                41907797            ],98            "output": 2782566299        },100        {101            "input": [102                [103                    999845,104                    2727,105                    218611,106                    750198,107                    372616,108                    729785,109                    849413,110                    429990,111                    20157,112                    224326,113                    445369,114                    673265,115                    960760,116                    827163,117                    369368,118                    926400,119                    598331,120                    395407121                ],122                651414123            ],124            "output": 5886610125        },126        {127            "input": [128                [129                    219144,130                    945121,131                    887315,132                    297758,133                    623865,134                    913917,135                    524280,136                    157517,137                    903857,138                    128775,139                    289544,140                    376299,141                    955582,142                    844420,143                    221271,144                    962458,145                    796074,146                    56465,147                    889268,148                    576081,149                    437467,150                    81345,151                    781023,152                    278337,153                    415576,154                    106657,155                    333536,156                    548645,157                    227782,158                    391678,159                    771871,160                    622340,161                    677081,162                    911901,163                    788465,164                    61421,165                    118470,166                    841196,167                    838997,168                    341705,169                    90761,170                    292833,171                    74132,172                    829956,173                    332018,174                    678339,175                    553831,176                    27312,177                    89956,178                    224392,179                    104987,180                    781044,181                    709330,182                    648746,183                    658527,184                    976838,185                    322790,186                    630509,187                    393252,188                    126193,189                    439008,190                    532437,191                    230698,192                    381287,193                    438206,194                    550730,195                    907340,196                    969114,197                    829997,198                    643930,199                    975756,200                    294425,201                    326400,202                    888218,203                    515725,204                    866033,205                    589559,206                    933915,207                    262851,208                    32953,209                    129198,210                    355494,211                    383292,212                    61609,213                    898331,214                    628020,215                    873425,216                    208283,217                    575006218                ],219                921560220            ],221            "output": 29602252222        },223        {224            "input": [225                [226                    746704,227                    926919,228                    205461,229                    995257,230                    951303,231                    292435,232                    564947,233                    452281,234                    204849,235                    829104,236                    362162,237                    915433,238                    979427,239                    648430,240                    947824,241                    448045,242                    593267,243                    982565,244                    374609,245                    20137246                ],247                900744248            ],249            "output": 8752895250        },251        {252            "input": [253                [254                    781654,255                    255447,256                    639135,257                    399879,258                    767941,259                    721564,260                    853751,261                    747520,262                    167382,263                    167744,264                    844103,265                    810361,266                    640293,267                    285855,268                    261994,269                    129024,270                    123924,271                    605824,272                    423896,273                    498604,274                    94835,275                    363030,276                    335047,277                    665941,278                    681323,279                    231700,280                    683192,281                    466306,282                    774215,283                    825836,284                    199305,285                    131800,286                    641686,287                    45246,288                    941560,289                    149818,290                    970658,291                    528783,292                    752140,293                    36586,294                    690676,295                    444633,296                    114322,297                    769610,298                    480383,299                    357653,300                    878714,301                    862545,302                    587603,303                    390833,304                    424260,305                    774443,306                    532315,307                    495134,308                    936402,309                    802485,310                    200011,311                    606441,312                    991906,313                    714087,314                    345030,315                    190419,316                    220400,317                    831122,318                    966703,319                    25757,320                    320689,321                    569711,322                    727786,323                    591251,324                    569215,325                    241025,326                    864395,327                    574094,328                    5931,329                    782641,330                    700077,331                    145453,332                    540879,333                    996494,334                    708118,335                    920587,336                    239931,337                    976193,338                    927956,339                    973898,340                    682152,341                    283105,342                    271072,343                    472866,344                    807411,345                    412593,346                    997169,347                    143853,348                    404359,349                    454747,350                    293645,351                    312539,352                    893102,353                    55803,354                    912966,355                    771802,356                    86698357                ],358                924773359            ],360            "output": 35406375361        },362        {363            "input": [364                [365                    685303,366                    903254,367                    747974,368                    951339,369                    29705,370                    591691,371                    273845,372                    130605,373                    395612,374                    552015,375                    409728,376                    426037,377                    702740,378                    727255,379                    884505,380                    97837,381                    276232,382                    544458,383                    765408,384                    456056385                ],386                162921387            ],388            "output": 9085310389        },390        {391            "input": [392                [393                    720279,394                    491077,395                    929262,396                    811102,397                    538120,398                    58664,399                    812857,400                    732118,401                    965490,402                    109361,403                    32443,404                    757105,405                    177974,406                    317446,407                    265306,408                    895620,409                    847590,410                    623176,411                    824538,412                    925917,413                    398383,414                    534637,415                    990857,416                    696326,417                    49096,418                    870648,419                    203364,420                    41089,421                    132684,422                    963777,423                    363413,424                    68694,425                    857471,426                    128173,427                    765580,428                    490160,429                    449068,430                    306771,431                    566246,432                    420078,433                    539418,434                    54655,435                    916593,436                    910922,437                    743206,438                    553866,439                    848733,440                    236627,441                    261150,442                    924700,443                    878973,444                    186981,445                    565462,446                    525,447                    611685,448                    521951,449                    678702,450                    993405,451                    942796,452                    210511,453                    127747,454                    366006,455                    713828,456                    892370,457                    135016,458                    450209,459                    761673,460                    232611,461                    499677,462                    940790,463                    227214,464                    819458,465                    252108,466                    762853,467                    364644,468                    720568,469                    720584,470                    141822,471                    125417,472                    40518,473                    293733,474                    499619,475                    943839,476                    404157,477                    607741,478                    494348,479                    192297,480                    982460,481                    935069,482                    26877483                ],484                480881485            ],486            "output": 34987568487        },488        {489            "input": [490                [491                    462670,492                    796177,493                    569994,494                    642212,495                    931330,496                    440076,497                    343158,498                    745909,499                    35500,500                    794874,501                    20521,502                    939985,503                    641783,504                    562861,505                    304358,506                    926052,507                    384102,508                    688206,509                    929371,510                    953925,511                    48197,512                    176656,513                    57208,514                    411891,515                    270350,516                    270381,517                    716642,518                    147171,519                    466179,520                    593626,521                    9977,522                    59015,523                    805242,524                    643200,525                    920753,526                    151065,527                    546606,528                    799583,529                    434133,530                    293901,531                    260916,532                    572502,533                    762552,534                    633035,535                    129989,536                    350251,537                    984499,538                    514240,539                    275326,540                    123348,541                    442797,542                    699144,543                    869460,544                    476632,545                    696178,546                    518067,547                    832087,548                    872870,549                    188732,550                    990938,551                    663217,552                    29636,553                    796004,554                    964155,555                    318754,556                    34748,557                    771617,558                    557144,559                    999561,560                    814347,561                    871317,562                    438929,563                    717510,564                    981,565                    842827,566                    599623,567                    342621,568                    838682,569                    167817,570                    290618,571                    753749,572                    419958,573                    82758,574                    535127,575                    984470,576                    132978,577                    998733,578                    535645,579                    836354,580                    998251,581                    734529,582                    742406,583                    359529,584                    450334,585                    692664,586                    292495,587                    901948,588                    962035,589                    298841590                ],591                751120592            ],593            "output": 34041581594        },595        {596            "input": [597                [598                    206967,599                    84782,600                    802976,601                    761732,602                    666544,603                    270193,604                    461535,605                    915356,606                    273148,607                    148439,608                    521369,609                    65830,610                    218719611                ],612                316667613            ],614            "output": 4065092615        },616        {617            "input": [618                [619                    665458,620                    844254,621                    688328,622                    194703,623                    659042,624                    568523,625                    806280,626                    520965,627                    921443,628                    831861,629                    448737,630                    646179,631                    7889,632                    218683,633                    854168,634                    906592,635                    66680,636                    507722,637                    245058,638                    123216,639                    535940,640                    38543,641                    359563,642                    406925,643                    963735,644                    627967,645                    739074,646                    220999,647                    100262648                ],649                495738650            ],651            "output": 11751612652        }653    ],654    "haskell_template": "maxScore :: [Int] -> Int -> Int\nmaxScore nums x ",655    "ocaml_template": "let maxScore (nums: int list) (x: int) : int =  ",656    "scala_template": "def maxScore(nums: List[Int],x: Int): Int = { \n    \n}",657    "java_template": "public static int maxScore(List<Integer> nums, int x) {\n\n}",658    "python_template": "class Solution(object):\n    def maxScore(self, nums, x):\n        \"\"\"\n        :type nums: List[int]\n        :type x: int\n        :rtype: int\n        \"\"\"\n        "659}