Max and Min in Array Python

PROGRAM TO FIND THE MAXIMUM AND MINIMUM ELEMENT OF AN ARRAY



def getMin(arr, n):
  
    # If there is single element, return it.
    # Else return minimum of first element 
    # and minimum of remaining array.
    return min(arr);
  
def getMax( arr, n):
  
    # If there is single element, return it.
    # Else return maximum of first element 
    # and maximum of remaining array.
    return max(arr);
  
# Driver code
arr = [12, 1234, 45, 67, 1]
n = len(arr)
print("Minimum element of array: "getMin(arr, n));
print("Maximum element of array: ", getMax(arr, n));
  

OUTPUT
Min of array: 1
Max of array: 1234

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java