You are viewing a single comment's thread. Return to all comments →
//my very simple cpp solutuions//
int minimumDistances(vector a) {
vector<int>b; bool flag =1; for(int i = 0;i < a.size();i++){ { int count; for(int j=i+1;j < a.size();j++){ if(a[i] ==a[j]){ count=abs(j - i); flag=0; } }b.push_back(count); } } if(flag == 1){ return -1; } int min=b[0]; for(int i = 0;i < b.size();i++){ if(b[i] < min){ min=b[i]; } } return min;
}
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 →
//my very simple cpp solutuions//
int minimumDistances(vector a) {
}