Question from Hackerblock - "AAKASH AND THE ARRAYS"

link of que. is - “https://hack.codingblocks.com/practice/p/362/1598
What’s Mistake in my code?
//code
#include
#include
using namespace std;
int main() {
int n,m,o;;
cin>>n>>m>>o;
int a[n],b[m],c[o];
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<m;i++) cin>>b[i];
for(int i=0;i<o;i++) cin>>c[i];
int curr=0,Min=max(max(a[0],b[0]),c[0])-min(min(a[0],b[0]),c[0]);
for(int i=0;i<n;i++){
for(int j=0;i<m;j++){
for(int k=0;k<o;k++){
curr=0;
curr=max(max(a[i],b[j]),c[k])-min(min(a[i],b[j]),c[k]);
if(curr<Min) Min=curr;
}
}
}
cout<<Min<<endl;
return 0;
}

Hi @Ayusinha, there’s just a minor error. Check your line 18, the one with loop counter j. The break condition is not correct. u hv written i instead of j.

Make this change and ur code will work :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.