You are viewing a single comment's thread. Return to all comments →
why you put *min_element(begin(arr)+1, end(arr))
why not *min_element(begin(arr), end(arr));
The element at begin(arr) is the first element in the sorted array (see http://www.cplusplus.com/reference/numeric/adjacent_difference/?kw=adjacent_difference for details on how this works). As a result, begin(arr)+1 points to the first absolute difference between two elements.