![]() |
VOOZH | about |
C++ defined functions to get smallest and largest elements among 2 or in a container using different functions. But there are also functions that are used to get both smallest and largest element using a single function, "minmax()" function achieves this task for us. This function is defined in "algorithm" header file. This article would deal in its implementation and other related functions.
The minimum value obtained is : 23 The maximum value obtained is : 53 The minimum value obtained is : 1 The maximum value obtained is : 6
Time Complexity: O(n) where n is the number of elements from which we have to find the minimum and maximum element.
Auxiliary Space: O(1)
The minimum value position obtained is : 1 The maximum value position obtained is : 0 The minimum value position obtained is : 1 The maximum value position obtained is : 5
Time Complexity: O(n)
Auxiliary Space: O(1)