Find the minimum and maximum element in a vector