Skip to content

Commit d299b21

Browse files
Create soln001.cpp
1 parent 66e1c4d commit d299b21

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

  • Problems/Mathematics/Day-02/sol/Avaneesh Verma
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(){
5+
int t;
6+
cin >> t;
7+
vector<int> results(t);
8+
9+
for(int i = 0; i < t; i++){
10+
int n;
11+
cin >> n;
12+
13+
vector<int> arr(n);
14+
for (int j = 0; j < n; j++){
15+
cin >> arr[j];
16+
}
17+
18+
int max = 0;
19+
for(int x = 0; x < n; x++){
20+
for(int y = 0; y < n; y++){
21+
if(abs(arr[x]-arr[y])>=max){
22+
max=abs(arr[x]-arr[y]);
23+
}
24+
}
25+
}
26+
int count = 0;
27+
for(int x = 0; x < n; x++){
28+
for(int y = 0; y < n; y++){
29+
if(abs(arr[x] - arr[y]) == max){
30+
count++;
31+
}
32+
}
33+
}
34+
results[i] = count;
35+
}
36+
for(int i = 0; i < t; i++){
37+
cout << results[i] << endl;
38+
}
39+
return 0;
40+
}

0 commit comments

Comments
 (0)