Find maximum and minimum value in an array

for maximum:

 

for minimum: