You are viewing a single comment's thread. Return to all comments →
Here is my solution in C :
int minimumDistances(int a_count, int* a) { int i,j,temp=-1,p=0,min=0; //p=0 -> flag for(i=0;i<a_count;i++) { for(j=i+1;j<a_count;j++) { if(a[i]==a[j]) { temp=j-i; if(p==0) { min=temp; p++; } if(min>temp) { min=temp; } } } } if(min!=0) return min; else return -1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Distances
You are viewing a single comment's thread. Return to all comments →
Here is my solution in C :