Check out example codes for "get min and max element index from vector c++". It will help you in understanding the concepts better.

Code Example 1

int maxElementIndex = std::max_element(v.begin(),v.end()) - v.begin();
int maxElement = *std::max_element(v.begin(), v.end());

int minElementIndex = std::min_element(v.begin(),v.end()) - v.begin();
int minElement = *std::min_element(v.begin(), v.end());

Learn ReactJs, React Native from akashmittal.com