I have a vector<int> v{1, 2, 3}
I have a function: int square(int x){return x*x;}
My question is: How do properly I find the argmax
(in v
) of square(v)
?
In this case 9
is bigger than 4
and 1
. Hence result should give 3
.
I could play with indices of "square(v)"
and then use that index to retrieve the element in v
. But maybe there is a c++ built-in function or a more elegant way to proceed?