You are viewing a single comment's thread. Return to all comments →
Here is your approach in C++:
#include <numeric> #include <iterator> using namespace std; typedef long long ll; int main() { ll iNum; cin >> iNum; vector<ll> iVec, sortVec; copy_n(istream_iterator<ll>(cin), iNum, back_inserter(iVec)); sort(begin(iVec),end(iVec)); adjacent_difference(begin(iVec),end(iVec), back_inserter(sortVec)); cout << *min_element(begin(sortVec)+1,end(sortVec)); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Absolute Difference in an Array
You are viewing a single comment's thread. Return to all comments →
Here is your approach in C++: