HORSES(practice(easy))

#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n,min=9999;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
sort(arr,arr+n);
// for(int i=0;i<n;i++)
// cout<<arr[i];
for(int i=0;i<n-1;i++)
{
int x=abs(arr[i]-arr[i+1]);
if(x<min)
min=x;
}
cout<<min;
}
return 0;
}

Can anyone help me in this code this is giving me correct answer but shows wrong answer on the online codechef platform

After each test case u should goto next line​:slightly_smiling_face::slightly_smiling_face:
Actually that’s not the problem u should increase the min range to 10^9 and this will give u AC for sure.

1 Like