Skip to content

Commit 25ee06a

Browse files
authored
Merge pull request #70 from InflixOP/patch1
Create #2799. Count Complete Subarrays in an Array.cpp
2 parents 922401b + 22a78da commit 25ee06a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
int countCompleteSubarrays(vector<int>& nums) {
4+
set<int>s(nums.begin(),nums.end());
5+
int size=s.size();
6+
int n=nums.size();
7+
int count=0;
8+
for(int i=0;i<n;i++){
9+
set<int>d;
10+
for(int j=i;j<n;j++){
11+
d.insert(nums[j]);
12+
if(d.size()==size) count++;
13+
}
14+
15+
}
16+
return count;
17+
}
18+
};

0 commit comments

Comments
 (0)