Class Solution
java.lang.Object
g2701_2800.s2799_count_complete_subarrays_in_an_array.Solution
2799 - Count Complete Subarrays in an Array.<p>Medium</p>
<p>You are given an array <code>nums</code> consisting of <strong>positive</strong> integers.</p>
<p>We call a subarray of an array <strong>complete</strong> if the following condition is satisfied:</p>
<ul>
<li>The number of <strong>distinct</strong> elements in the subarray is equal to the number of distinct elements in the whole array.</li>
</ul>
<p>Return <em>the number of <strong>complete</strong> subarrays</em>.</p>
<p>A <strong>subarray</strong> is a contiguous non-empty part of an array.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,3,1,2,2]</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> The complete subarrays are the following: [1,3,1,2], [1,3,1,2,2], [3,1,2] and [3,1,2,2].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [5,5,5,5]</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong> The array consists only of the integer 5, so any subarray is complete. The number of subarrays that we can choose is 10.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 1000</code></li>
<li><code>1 <= nums[i] <= 2000</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countCompleteSubarrays
public int countCompleteSubarrays(int[] nums)
-