Position in Vector using STL
c++, stl
Solution
`min_element` already gives you the iterator, no need to invoke `find` (additionally, it's inefficient because it's twice the work). Use `distance` or the `-` operator:
cout << "min value at " << min_element(v2.begin(), v2.end()) - v2.begin();
Problem
im trying to locate the position of the minimum value in a vector, using STL find algorithm (and the min_element algorithm), but instead of returning the postion, its just giving me the value. E.g, if the minimum value is it, is position will be returned as 8 etc. What am I doing wrong here? ``` int value = *min_element(v2.begin(), v2.end()); cout << "min value at position " << *find(v2.begin(), v2.end(), value); ```