You are viewing a single comment's thread. Return to all comments →
C++
int minimumDistances(vector<int> a) { vector<int> distance; for (int i = 0; i < a.size(); i++) { for (int j = i + 1; j < a.size(); j++){ if (a[i] == a[j]) { distance.push_back(j - i); } } } sort(distance.begin(), distance.end()); return (distance.size() > 0) ? distance[0] : -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 →
C++