Hello,
This is a video Solution for Problem #1 which is CoronaVirus Spread (COVID19). Problem 3, Triple Sort will be coming out soon.
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int t, maxx=-1, minn=100000000;
cin >> t;
for(int k=0; k<t; k++){
maxx=-1; minn=10000000;
int n;
cin >> n;
int arr[n];
for(int i=0; i<n; i++){
cin >> arr[i];
}
for(int i=0; i<n; i++){
int counter=0;
int testing=arr[i];
for(int j=i; j<n; j++){
if(arr[j]-2<=testing){
testing=arr[j];
counter++;
}
else break;
}
testing=arr[i];
for(int j=i; j>=0; j--){
if(arr[j]+2>=testing){
testing=arr[j];
counter++;
}
else break;
}
counter--;
minn=min(minn, counter);
maxx=max(maxx,counter);
}
cout << minn << " " << maxx << endl;
}
}