You are viewing a single comment's thread. Return to all comments →
short c++ solution
#define all(a) (a).begin(), (a).end() int maxMin(int k, vector<int> arr) { sort(all(arr)); int n = arr.size(); int best = 1e9; for (int i = 0; i <= n-k; i++) { best = min(best, arr[k-1+i]-arr[i]); } return best; }
Seems like cookies are disabled on this browser, please enable them to open this website
Max Min
You are viewing a single comment's thread. Return to all comments →
short c++ solution