CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes302downloads
meta.json563 linesDownload Raw Back to transformed_array
1{2    "id": 3651,3    "name": "transformed_array",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/transformed-array/",6    "date": "2024-12-01 00:00:00",7    "task_description": "You are given an integer array `nums` that represents a circular array. Your task is to create a new array `result` of the **same** size, following these rules: For each index `i` (where `0 <= i < nums.length`), perform the following **independent** actions: If `nums[i] > 0`: Start at index `i` and move `nums[i]` steps to the **right** in the circular array. Set `result[i]` to the value of the index where you land. If `nums[i] < 0`: Start at index `i` and move `abs(nums[i])` steps to the **left** in the circular array. Set `result[i]` to the value of the index where you land. If `nums[i] == 0`: Set `result[i]` to `nums[i]`. Return the new array `result`. **Note:** Since `nums` is circular, moving past the last element wraps around to the beginning, and moving before the first element wraps back to the end. **Example 1:** **Input:** nums = [3,-2,1,1] **Output:** [1,1,1,3] **Explanation:** For `nums[0]` that is equal to 3, If we move 3 steps to right, we reach `nums[3]`. So `result[0]` should be 1. For `nums[1]` that is equal to -2, If we move 2 steps to left, we reach `nums[3]`. So `result[1]` should be 1. For `nums[2]` that is equal to 1, If we move 1 step to right, we reach `nums[3]`. So `result[2]` should be 1. For `nums[3]` that is equal to 1, If we move 1 step to right, we reach `nums[0]`. So `result[3]` should be 3. **Example 2:** **Input:** nums = [-1,4,-1] **Output:** [-1,-1,4] **Explanation:** For `nums[0]` that is equal to -1, If we move 1 step to left, we reach `nums[2]`. So `result[0]` should be -1. For `nums[1]` that is equal to 4, If we move 4 steps to right, we reach `nums[2]`. So `result[1]` should be -1. For `nums[2]` that is equal to -1, If we move 1 step to left, we reach `nums[1]`. So `result[2]` should be 4. **Constraints:** `1 <= nums.length <= 100` `-100 <= nums[i] <= 100`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [3,-2,1,1]",12            "output": "[1,1,1,3] "13        },14        {15            "label": "Example 2",16            "input": "nums = [-1,4,-1]",17            "output": "[-1,-1,4] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                20,24                -26,25                14,26                -18,27                -48,28                74,29                0,30                -26,31                -55,32                -82,33                19,34                -55,35                1,36                -93,37                -62,38                -31,39                -49,40                -20,41                25,42                84,43                -33,44                -75,45                59,46                64,47                -7,48                5,49                -20,50                -89,51                3,52                27,53                4,54                -57,55                25,56                -38,57                -94,58                -15,59                -92,60                75,61                -43,62                60,63                -74,64                -33,65                -35,66                -22,67                -5,68                -10,69                24,70                80,71                -73,72                67,73                -92,74                58,75                9,76                -31,77                30,78                -56,79                -7880            ],81            "output": [82                -33,83                25,84                -49,85                -35,86                -93,87                59,88                0,89                -43,90                19,91                -33,92                27,93                -93,94                -93,95                -94,96                -82,97                -33,98                -7,99                30,100                -22,101                24,102                -5,103                -18,104                -7,105                4,106                -20,107                4,108                0,109                9,110                -57,111                -78,112                -94,113                -57,114                20,115                9,116                30,117                -33,118                -26,119                -56,120                9,121                -35,122                64,123                -55,124                -26,125                -75,126                60,127                -15,128                -93,129                -93,130                25,131                14,132                -31,133                9,134                -48,135                59,136                -89,137                -78,138                -15139            ]140        },141        {142            "input": [143                -23,144                42,145                69,146                -97,147                -58,148                97,149                -47,150                65,151                45,152                -93,153                31,154                -44,155                -78,156                -49,157                81,158                60,159                51,160                -80,161                -74,162                87,163                20,164                1,165                86,166                -32,167                -80,168                58,169                -23,170                6,171                -92,172                9,173                -99,174                -11,175                44,176                71,177                56,178                50,179                6,180                -64,181                -61182            ],183            "output": [184                51,185                -58,186                44,187                -32,188                -80,189                -80,190                -64,191                71,192                81,193                71,194                69,195                -47,196                -78,197                -97,198                -80,199                6,200                -92,201                60,202                86,203                -92,204                42,205                86,206                -99,207                -99,208                86,209                97,210                -97,211                71,212                81,213                -61,214                -93,215                20,216                -64,217                -23,218                -78,219                65,220                -97,221                -78,222                51223            ]224        },225        {226            "input": [227                61,228                -63,229                -16,230                10,231                -39,232                -16,233                -95,234                -44,235                -16,236                21,237                4,238                18,239                -56,240                53,241                39,242                69,243                29,244                -87,245                43,246                -75,247                -81,248                -3,249                -66,250                -18,251                -73,252                38,253                9,254                75,255                -98,256                43,257                67,258                -49,259                100,260                -9,261                62,262                32,263                -13,264                -2,265                -81,266                79,267                88,268                -1,269                16,270                27,271                81,272                -90,273                -88,274                15,275                60,276                33,277                -20,278                -12,279                86,280                20,281                83,282                10,283                -55,284                88,285                82,286                32,287                98,288                7,289                -66,290                60,291                54,292                50,293                -42,294                -99,295                69,296                -29,297                -98,298                -51,299                -54,300                65,301                -63,302                -16,303                11,304                -82305            ],306            "output": [307                7,308                29,309                54,310                53,311                27,312                -99,313                -99,314                -1,315                -98,316                67,317                39,318                43,319                62,320                -42,321                20,322                -95,323                -90,324                -16,325                7,326                -66,327                -87,328                43,329                62,330                -16,331                43,332                60,333                32,334                -73,335                -16,336                -54,337                -75,338                98,339                83,340                -73,341                43,342                -99,343                -18,344                32,345                32,346                88,347                -20,348                88,349                82,350                -98,351                15,352                -9,353                -13,354                -66,355                67,356                -39,357                67,358                79,359                98,360                65,361                32,362                50,363                -63,364                -99,365                -66,366                53,367                -16,368                69,369                -63,370                -90,371                88,372                -2,373                -73,374                -88,375                32,376                88,377                -20,378                -81,379                43,380                98,381                18,382                32,383                21,384                65385            ]386        },387        {388            "input": [389                55,390                -64,391                -7,392                -6,393                -30,394                -37,395                16,396                58,397                57,398                33,399                62,400                82,401                -6,402                94,403                65,404                0,405                -74,406                -32,407                50,408                70,409                -85,410                55,411                43,412                -70,413                38,414                75,415                98,416                86,417                -79,418                41,419                -80,420                65,421                68,422                -17,423                -15,424                -92,425                84,426                5,427                -93,428                -8,429                -10,430                32,431                46,432                40433            ],434            "output": [435                82,436                75,437                -8,438                32,439                50,440                -6,441                43,442                55,443                55,444                46,445                -79,446                -37,447                16,448                70,449                -92,450                0,451                -80,452                41,453                38,454                -64,455                -70,456                68,457                55,458                32,459                50,460                -6,461                84,462                75,463                5,464                98,465                -93,466                57,467                -6,468                -74,469                70,470                65,471                68,472                46,473                -17,474                65,475                -80,476                41,477                55,478                -8479            ]480        },481        {482            "input": [483                1,484                -93,485                55,486                -75,487                27,488                83,489                4,490                93,491                -63,492                60,493                89,494                46,495                7,496                5,497                -67,498                -62,499                -49,500                -18,501                77,502                2,503                44,504                48,505                76,506                -58,507                99,508                92,509                -2,510                -99,511                -35,512                -32,513                -61,514                -26,515                49,516                95,517                -69518            ],519            "output": [520                -93,521                5,522                76,523                95,524                -26,525                77,526                89,527                -61,528                -62,529                -69,530                -32,531                76,532                2,533                77,534                -18,535                -58,536                55,537                -69,538                92,539                48,540                -32,541                -69,542                -35,543                1,544                77,545                7,546                99,547                95,548                -35,549                49,550                27,551                83,552                46,553                -58,554                1555            ]556        }557    ],558    "haskell_template": "constructTransformedArray :: [Int] -> [Int]\nconstructTransformedArray nums ",559    "ocaml_template": "let constructTransformedArray (nums: int list) : int list =  ",560    "scala_template": "def constructTransformedArray(nums: List[Int]): List[Int] = { \n    \n}",561    "java_template": "class Solution {\n    public int[] constructTransformedArray(int[] nums) {\n        \n    }\n}",562    "python_template": "class Solution(object):\n    def constructTransformedArray(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: List[int]\n        \"\"\"\n        "563}