Given a list of N integers, find the maximum and minimum elements position in the list.,The naive approach will be to traverse in the list and keep track of the minimum and maximum along with their indices. We have to do N comparisons for minimum and at the same time N comparisons for maximum.Below is the implementation of the naive approach.,Python inbuilt function allows us to find it in one line, we can find the minimum in the list using the min[] function and then us index[] function to find out the index of that minimum element. Similarly we can do the same for finding out the maximum element using max[] function and then find out the index of the maximum element using index[] inbuilt function in python.Note : index[] returns index of first occurrence in case there are multiple occurrences of an element. So if maximum [or minimum] occurs more than once, the first occurrence is returned.,Python Find the index of Minimum element in list
Find index of max value in list python
Input: 3, 4, 1, 3, 4, 5
Output: The maximum is at position 6
The minimum is at position 3
Minimum Element in the list[8, 1, 7, 10, 5] is 1
Maximum Element in the list[8, 1, 7, 10, 5] is 10
The maximum is at position 6
The minimum is at position 3
Bài Viết Liên Quan
Toplist mới
#1
Top 8 kết quả vòng 1 thi hành an dân sự 2023
7 tháng trước#2
Top 6 vở bài tập tiếng việt tiết 8 2023
7 tháng trước#3
Top 9 thuốc bổ âm thường uống lục nào 2023
7 tháng trước#4
Top 5 luật tổ chức chính phủ hợp nhất pdf 2023
7 tháng trước#6
Top 5 xác định tên của 10 linh kiện trên mạch 2023
7 tháng trước#7
Top 9 bươm bướm nâu bay vào nhà là điềm gì 2023
7 tháng trước#8
Top 3 giáo án nhận biết đồ dùng để ăn 2023
7 tháng trước#9
Top 10 tổng hợp kiến thức công nghệ 7 học kì 1 2023
7 tháng trướcBài mới nhất
Chủ Đề
Hỏi Đáp
Là gì
Toplist
Mẹo Hay
Địa Điểm Hay
mẹo hay
Học Tốt
programming
Nghĩa của từ
Công Nghệ
Khỏe Đẹp
Bao nhiêu
đánh giá
Top List
bao nhieu
bao nhiêu
hướng dẫn
Bài tập
So Sánh
Tiếng anh
So sánh
Xây Đựng
Ngôn ngữ
Bài Tập
Sản phẩm tốt
Ở đâu
Thế nào
Hướng dẫn
Dịch
Đại học
Tại sao
Máy tính
Món Ngon
Khoa Học
Bao lâu
Vì sao
Hà Nội