CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes572downloads
1{2    "id": 3163,3    "name": "subarrays_distinct_element_sum_of_squares_i",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/subarrays-distinct-element-sum-of-squares-i/",6    "date": "2023-10-14 00:00:00",7    "task_description": "You are given a **0-indexed **integer array `nums`. The **distinct count** of a subarray of `nums` is defined as: Let `nums[i..j]` be a subarray of `nums` consisting of all the indices from `i` to `j` such that `0 <= i <= j < nums.length`. Then the number of distinct values in `nums[i..j]` is called the distinct count of `nums[i..j]`. Return _the sum of the **squares** of **distinct counts** of all subarrays of _`nums`. A subarray is a contiguous **non-empty** sequence of elements within an array. **Example 1:** ``` **Input:** nums = [1,2,1] **Output:** 15 **Explanation:** Six possible subarrays are: [1]: 1 distinct value [2]: 1 distinct value [1]: 1 distinct value [1,2]: 2 distinct values [2,1]: 2 distinct values [1,2,1]: 2 distinct values The sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 + 22 + 22 + 22 = 15. ``` **Example 2:** ``` **Input:** nums = [1,1] **Output:** 3 **Explanation:** Three possible subarrays are: [1]: 1 distinct value [1]: 1 distinct value [1,1]: 1 distinct value The sum of the squares of the distinct counts in all subarrays is equal to 12 + 12 + 12 = 3. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [1,2,1]",12            "output": "15 "13        },14        {15            "label": "Example 2",16            "input": "nums = [1,1]",17            "output": "3 "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                39,24                57,25                86,26                40,27                59,28                42,29                30,30                11,31                1,32                54,33                57,34                36,35                35,36                23,37                8,38                51,39                24,40                88,41                3242            ],43            "output": 1279644        },45        {46            "input": [47                88,48                98,49                56,50                36,51                98,52                46,53                87,54                58,55                4,56                52,57                40,58                1,59                14,60                76,61                66,62                6,63                81,64                21,65                20,66                48,67                79,68                51,69                85,70                59,71                46,72                77,73                87,74                38,75                4,76                69,77                88,78                29,79                58,80                30,81                85,82                91,83                24,84                57,85                3386            ],87            "output": 18509688        },89        {90            "input": [91                84,92                87,93                16,94                39,95                47,96                66,97                74,98                83,99                61,100                59,101                36,102                47,103                78,104                1,105                16,106                84,107                23,108                13,109                43,110                80,111                85,112                87,113                85,114                29,115                84,116                86,117                11,118                90,119                56,120                52,121                51,122                66,123                97,124                58,125                40,126                44,127                58,128                30,129                4,130                22,131                80,132                60,133                93,134                93,135                57,136                13,137                71,138                35,139                28,140                19,141                54,142                3,143                30,144                76,145                70,146                98,147                19,148                71,149                55,150                19,151                86,152                86,153                12,154                18,155                11,156                94,157                82,158                5,159                37,160                52,161                13,162                7,163                52,164                46,165                46,166                90,167                87,168                66169            ],170            "output": 2057604171        },172        {173            "input": [174                48,175                21,176                88,177                39,178                88,179                16,180                49,181                56,182                65,183                82,184                61,185                84,186                79,187                31,188                27,189                25,190                54,191                7,192                15,193                39,194                16,195                93,196                39,197                17,198                46,199                30,200                92,201                81,202                92,203                93,204                28,205                26,206                78,207                53,208                100,209                88,210                56,211                4,212                30,213                46,214                22,215                47,216                81,217                66,218                53,219                4,220                29,221                29,222                50,223                46,224                80,225                90,226                15,227                59,228                52,229                29,230                17,231                98,232                87,233                34234            ],235            "output": 691347236        },237        {238            "input": [239                47,240                90,241                80,242                67,243                76,244                12,245                34,246                7,247                16,248                97,249                48,250                68,251                73,252                38,253                57,254                2,255                98,256                22,257                30,258                93,259                65,260                53,261                77,262                28,263                46,264                11,265                9,266                25,267                38,268                84,269                95,270                16,271                62,272                1,273                46,274                48,275                99,276                10,277                34,278                72,279                12,280                6,281                49,282                53,283                94,284                6,285                87,286                85,287                90,288                69,289                18,290                48,291                69,292                64,293                57,294                90,295                40,296                85,297                6,298                98,299                14,300                5,301                21,302                26,303                91,304                84,305                46,306                54,307                43,308                77,309                65,310                11,311                7,312                96,313                63,314                98,315                93,316                66,317                30,318                8,319                82,320                31,321                64,322                93,323                30,324                31,325                82,326                40327            ],328            "output": 3247735329        }330    ],331    "haskell_template": "sumCounts :: [Int] -> Int\nsumCounts nums ",332    "ocaml_template": "let sumCounts (nums: int list) : int =  ",333    "scala_template": "def sumCounts(nums: List[Int]): Int = { \n    \n}",334    "java_template": "class Solution {\n    public int sumCounts(List<Integer> nums) {\n        \n    }\n}",335    "python_template": "class Solution(object):\n    def sumCounts(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        "336}