Skip to content

Commit 9984f59

Browse files
authored
Merge pull request #266 from Naman2251/main
Create day002sol01
2 parents be24881 + a31f63c commit 9984f59

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
5+
int main() {
6+
int t;
7+
cin>>t;
8+
while(t--) {
9+
long long n;
10+
cin>>n;
11+
int a[n];
12+
for(long long i=0; i<n; i++) cin>>a[i];
13+
sort(a, a+n);
14+
long long minn=0,maxx=0;
15+
for(long long i=0; i<n;i++) {
16+
if(a[i]==a[0]) minn++;
17+
if(a[i]==a[n-1]) maxx++;
18+
}
19+
if(a[0]==a[n-1]) cout<<n*(n-1)<<endl;
20+
else cout<<minn*maxx*2<<endl;
21+
}
22+
}

0 commit comments

Comments
 (0)