Anyone can help here ?
All given test cases as well as some possible test cases self made, are getting passed.
Still on submitting some boundary cases gets failed i think…
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
long n;
cin>>n;
long arr[n];
for(long i=0;i<n;i++)
cin>>arr[i];
long maxi=INT_MIN,mini=INT_MAX,fposn=-1,lposn=-1;
for(long i=n-1;i>=0;i--){
if(arr[i]>maxi){
maxi=arr[i];
lposn=i+1;
}
mini=min(mini,arr[i]);
}
maxi=INT_MIN;
for(long i=0;i<n;i++){
if(arr[i]>maxi){
maxi=arr[i];
fposn=i+1;
}
}
if(mini==maxi)
cout<<0<<endl;
else
cout<<abs((n/2) -abs(lposn-fposn))<<endl;
}
return 0;
}