You are viewing a single comment's thread. Return to all comments →
c++
int maxMin(int k, vector<int> arr) { int res = INT_MAX; std::sort(arr.begin(), arr.end()); for(int i = 0; i + k -1 < arr.size(); ++i){ res = std::min(res, arr[i+k-1] - arr[i]); } return res; }
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 →
c++