CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes302downloads
1{2    "id": 2777,3    "name": "find_the_distinct_difference_array",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/find-the-distinct-difference-array/",6    "date": "2023-04-30 00:00:00",7    "task_description": "You are given a **0-indexed** array `nums` of length `n`. The **distinct difference** array of `nums` is an array `diff` of length `n` such that `diff[i]` is equal to the number of distinct elements in the suffix `nums[i + 1, ..., n - 1]` **subtracted from** the number of distinct elements in the prefix `nums[0, ..., i]`. Return _the **distinct difference** array of _`nums`. Note that `nums[i, ..., j]` denotes the subarray of `nums` starting at index `i` and ending at index `j` inclusive. Particularly, if `i > j` then `nums[i, ..., j]` denotes an empty subarray. **Example 1:** ``` **Input:** nums = [1,2,3,4,5] **Output:** [-3,-1,1,3,5] **Explanation:** For index i = 0, there is 1 element in the prefix and 4 distinct elements in the suffix. Thus, diff[0] = 1 - 4 = -3. For index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1. For index i = 2, there are 3 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 3 - 2 = 1. For index i = 3, there are 4 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 4 - 1 = 3. For index i = 4, there are 5 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 5 - 0 = 5. ``` **Example 2:** ``` **Input:** nums = [3,2,3,4,2] **Output:** [-2,-1,0,2,3] **Explanation:** For index i = 0, there is 1 element in the prefix and 3 distinct elements in the suffix. Thus, diff[0] = 1 - 3 = -2. For index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1. For index i = 2, there are 2 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 2 - 2 = 0. For index i = 3, there are 3 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 3 - 1 = 2. For index i = 4, there are 3 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 3 - 0 = 3. ``` **Constraints:** `1 <= n == nums.length <= 50` `1 <= nums[i] <= 50`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [1,2,3,4,5]",12            "output": "[-3,-1,1,3,5] "13        },14        {15            "label": "Example 2",16            "input": "nums = [3,2,3,4,2]",17            "output": "[-2,-1,0,2,3] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                44,24                1,25                46,26                10,27                5,28                7,29                50,30                2,31                44,32                32,33                1,34                26,35                34,36                21,37                33,38                30,39                5,40                6,41                33,42                12,43                13,44                1,45                3746            ],47            "output": [48                -17,49                -16,50                -14,51                -12,52                -11,53                -9,54                -7,55                -5,56                -4,57                -2,58                -2,59                0,60                2,61                4,62                5,63                7,64                8,65                10,66                11,67                13,68                15,69                16,70                1871            ]72        },73        {74            "input": [75                3776            ],77            "output": [78                179            ]80        },81        {82            "input": [83                17,84                31,85                15,86                24,87                8,88                5,89                41,90                12,91                33,92                23,93                44,94                3,95                33,96                45,97                45,98                44,99                35,100                37,101                2,102                31,103                11,104                38,105                5,106                10,107                4,108                48,109                35,110                1,111                40,112                3,113                13114            ],115            "output": [116                -22,117                -21,118                -19,119                -17,120                -15,121                -14,122                -12,123                -10,124                -9,125                -7,126                -6,127                -5,128                -4,129                -3,130                -2,131                -1,132                0,133                2,134                4,135                5,136                7,137                9,138                10,139                12,140                14,141                16,142                17,143                19,144                21,145                22,146                24147            ]148        },149        {150            "input": [151                13,152                1,153                39,154                29,155                17,156                39157            ],158            "output": [159                -3,160                -1,161                0,162                2,163                4,164                5165            ]166        },167        {168            "input": [169                14,170                21,171                34,172                43,173                2,174                3,175                48,176                17,177                1,178                16,179                40,180                50,181                27,182                36,183                6,184                28,185                26,186                2,187                44,188                33,189                43,190                6,191                13,192                20,193                21,194                4,195                6,196                41,197                38,198                19,199                39,200                42,201                14,202                7,203                35,204                4,205                39,206                12,207                6,208                10,209                25,210                18211            ],212            "output": [213                -32,214                -31,215                -29,216                -28,217                -27,218                -25,219                -23,220                -21,221                -19,222                -17,223                -15,224                -13,225                -11,226                -9,227                -8,228                -6,229                -4,230                -3,231                -1,232                1,233                2,234                2,235                4,236                6,237                7,238                8,239                8,240                10,241                12,242                14,243                15,244                17,245                18,246                20,247                22,248                23,249                24,250                26,251                27,252                29,253                31,254                33255            ]256        },257        {258            "input": [259                10,260                8,261                44,262                4,263                33,264                21,265                50,266                46,267                29,268                41,269                45,270                24,271                30,272                10,273                43,274                29,275                38,276                31,277                14,278                7,279                3,280                19,281                27,282                32,283                5,284                43,285                24,286                32,287                6,288                15,289                24290            ],291            "output": [292                -24,293                -22,294                -20,295                -18,296                -16,297                -14,298                -12,299                -10,300                -9,301                -7,302                -5,303                -4,304                -2,305                -1,306                0,307                1,308                3,309                5,310                7,311                9,312                11,313                13,314                15,315                16,316                18,317                19,318                19,319                20,320                22,321                24,322                25323            ]324        },325        {326            "input": [327                2,328                2,329                1,330                39,331                18,332                15,333                15,334                3,335                18,336                4,337                47,338                6,339                8,340                26,341                28,342                37,343                30,344                4,345                22,346                2,347                12,348                12,349                32,350                13,351                18,352                39,353                13354            ],355            "output": [356                -17,357                -17,358                -15,359                -14,360                -13,361                -12,362                -11,363                -9,364                -9,365                -8,366                -6,367                -4,368                -2,369                0,370                2,371                4,372                6,373                7,374                9,375                10,376                11,377                12,378                14,379                15,380                16,381                17,382                18383            ]384        },385        {386            "input": [387                44,388                41,389                17,390                11,391                3,392                21,393                7,394                1,395                23,396                48,397                39,398                41,399                44,400                26,401                28,402                46,403                46,404                9,405                5,406                29,407                38,408                5,409                1,410                4,411                17412            ],413            "output": [414                -18,415                -17,416                -16,417                -14,418                -12,419                -10,420                -8,421                -7,422                -5,423                -3,424                -1,425                0,426                1,427                3,428                5,429                6,430                7,431                9,432                10,433                12,434                14,435                15,436                16,437                18,438                19439            ]440        },441        {442            "input": [443                19,444                35,445                2,446                8,447                30,448                46449            ],450            "output": [451                -4,452                -2,453                0,454                2,455                4,456                6457            ]458        },459        {460            "input": [461                19,462                41,463                16,464                40,465                20466            ],467            "output": [468                -3,469                -1,470                1,471                3,472                5473            ]474        }475    ],476    "haskell_template": "distinctDifferenceArray :: [Int] -> [Int]\ndistinctDifferenceArray nums ",477    "ocaml_template": "let distinctDifferenceArray (nums: int list) : int list =  ",478    "scala_template": "def distinctDifferenceArray(nums: List[Int]): List[Int] = { \n    \n}",479    "java_template": "class Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        \n    }\n}",480    "python_template": "class Solution(object):\n    def distinctDifferenceArray(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: List[int]\n        \"\"\"\n        "481}