Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
count-complete-subarrays-in-an-array.json30 linesDownload Raw Back to root
1{2  "id": 2856,3  "name": "count-complete-subarrays-in-an-array",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/count-complete-subarrays-in-an-array/",6  "date": "2023-07-23",7  "task_description": "You are given an array `nums` consisting of **positive** integers. We call a subarray of an array **complete** if the following condition is satisfied: The number of **distinct** elements in the subarray is equal to the number of distinct elements in the whole array. Return _the number of **complete** subarrays_. A **subarray** is a contiguous non-empty part of an array. **Example 1:** ``` **Input:** nums = [1,3,1,2,2] **Output:** 4 **Explanation:** The complete subarrays are the following: [1,3,1,2], [1,3,1,2,2], [3,1,2] and [3,1,2,2]. ``` **Example 2:** ``` **Input:** nums = [5,5,5,5] **Output:** 10 **Explanation:** The array consists only of the integer 5, so any subarray is complete. The number of subarrays that we can choose is 10. ``` **Constraints:** `1 <= nums.length <= 1000` `1 <= nums[i] <= 2000`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,3,1,2,2]",12      "output": "4 "13    },14    {15      "label": "Example 2",16      "input": "nums = [5,5,5,5]",17      "output": "10 "18    }19  ],20  "constraints": [21    "The number of distinct elements in the subarray is equal to the number of distinct elements in the whole array.",22    "1 <= nums.length <= 1000",23    "1 <= nums[i] <= 2000"24  ],25  "python_template": "class Solution(object):\n    def countCompleteSubarrays(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        ",26  "java_template": "class Solution {\n    public int countCompleteSubarrays(int[] nums) {\n        \n    }\n}",27  "metadata": {28    "func_name": "countCompleteSubarrays"29  }30}