Pk finds it difficult to judge the minimum element in the list of elements given to him.

Pk finds it difficult to judge the minimum element in the list of elements given to him. Your task is to develop the algorithm in order to find the minimum element.

Sample Input :
5
3 4 9 1 6

Sample Output :
1

#method to find minimum element from a list
def pk_find_min(arr): n = len(arr) #initialize first list element to 'min' min = arr[0] for i in range(n-1,0,-1): #compare list element with 'min' and overwrite 'min' with minimum element if min > arr[i]: min = arr[i] return(min) if __name__ == "__main__": n = int(input()) ip_list = list(input().split()) print(pk_find_min(ip_list))
Enter fullscreen mode
Exit fullscreen mode

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Firebase free hosting archives solid future. Looking for the best power bi training institute to master data analytics ?. Cloudy | #1 secure, private, and affordable online storage solutions.