Use the following feature:
as a starting value, if you want to find minimum, and
, if you want to find maximum:
Cycle through all possible pairs of point and find the distance between them, compare with current minimum and decrease the current minimum if the distance is smaller. The opposite with maximum. When iterations are done, your current minimum will be the answer. Same thing with maximum.