It's O(n). It's a general algorithm, you can't find the max/min in the general case without checking all of them. Python doesn't even have a built-in sorted collection type that would make the check easy to specialize.

A for loop would have the same algorithmic complexity, but would run slower in the typical case, since min/max (on CPython anyway) are running an equivalent loop at the C layer, avoiding bytecode interpreter overhead, which the for loop would incur.

Answer from ShadowRanger on Stack Overflow
Discussions

python - Time complexity of min, max on sets - Stack Overflow
min, max have O(N) time complexity because they have to loop over the given list/string and check every index to find min/max. But I am wondering what would be the time complexity of min,max if use... More on stackoverflow.com
🌐 stackoverflow.com
performance - How efficient is Python's max function - Stack Overflow
If you want to maximize based on ... k is the time complexity of "someFunc." ... But yes for normal case it should just iterate over the list and find the max using normal compare function. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. 475 What do I use for a max-heap implementation in Python... More on stackoverflow.com
🌐 stackoverflow.com
Python: Time complexity of min() function inside for loop - Stack Overflow
I'm calculating time complexities of algorithms and I assumed both code below to have time complexities of O(n^2) However my books says first code is O(n^2) and second one is O(n). I don't understand why. Both are using min/max, so whats the difference? More on stackoverflow.com
🌐 stackoverflow.com
Time complexity of min(set, function)
https://pypi.python.org/pypi/pqdict/ More on reddit.com
🌐 r/Python
12
2
March 11, 2017
🌐
CopyProgramming
copyprogramming.com › howto › time-complexity-of-min-and-max-on-a-list-of-constant-size
Python min Function Time Complexity: Complete Guide for 2026 - Python min function time complexity complete guide
February 4, 2026 - Python's implementation uses a ... size has fixed n, like my_list = [1, 2, 3] where len=3 always. Time complexity of min(my_list) or max(my_list) is O(1), as constant work scales constantly....
🌐
Python
wiki.python.org › moin › TimeComplexity
TimeComplexity - Python Wiki
[3] = For these operations, the worst case n is the maximum size the container ever achieved, rather than just the current size.
🌐
GeeksforGeeks
geeksforgeeks.org › python › complexity-cheat-sheet-for-python-operations
Complexity Cheat Sheet for Python Operations - GeeksforGeeks
July 12, 2025 - This cheat sheet is designed to help developers understand the average and worst-case complexities of common operations for these data structures that help them write optimized and efficient code in Python. Python's list is an ordered, mutable sequence, often implemented as a dynamic array. Below are the time complexities for common list operations:
Find elsewhere
🌐
Enterprise DNA
blog.enterprisedna.co › python-min-function
Python min() Function: 10 Real-World Examples – Master Data Skills + AI
The time complexity of the min function in Python is O(n), where n is the number of elements in the input iterable. This is because the min function performs a single pass through the input iterable to find the minimum value. Python’s max and min functions serve the same purpose but in opposite directions.
🌐
Python Pool
pythonpool.com › home › blog › using python max function like a pro | python max()
Using Python Max Function Like a Pro | Python max() - Python Pool
June 14, 2021 - ... The time complexity of the python max function is O(n). Unlike max functions in other programming languages like C++, it offers a variety of uses. We can apply it on the string, which is not possible in other languages.
🌐
Medium
medium.com › @lcao_5526 › 3-ways-to-find-the-largest-number-in-python-and-their-complexities-49f2a1e221ee
3 Ways to Find the Largest Number in Python and Their Complexities | by Lulu Cao | Medium
April 13, 2024 - Under the hood, the Python max() function works similarly to our solution 1 above. So, it shares the time complexity of O(N) and the space complexity of O(1).
🌐
AlgoCademy
algocademy.com › link
Time Complexity Practice 1 in Python | AlgoCademy
sorted(): O(n log n) - Sorting algorithms like Timsort (used in Python) have a time complexity of O(n log n). sum(): O(n) - Summing up n elements requires iterating through each element once. max()/min(): O(n) - Finding the maximum or minimum ...
🌐
After Academy
afteracademy.com › blog › find-the-minimum-and-maximum-value
Find minimum and maximum value in an array - Interview Problem
October 6, 2019 - How is the space complexity derived to be O(logn)? Why there are 2 base cases? What if we remove the base case with array size 2? Why prefer mid = start + (end - start)/2 over (start + end)/2 when calculating middle of the array ? Can the number of comparisons be decreased further? In this approach, we pick array elements in pairs and update the min and max.
🌐
Reddit
reddit.com › r/python › time complexity of min(set, function)
r/Python on Reddit: Time complexity of min(set, function)
March 11, 2017 -

I'm implementing an algorithm and I need a data structure with both very fast lookup of arbitrary elements like you get from a hash table and similar to a priority queue very fast lookup of the highest priority element ordered by a key associated with each item.

Is there anyway I can accomplish this? I thought of just using a set and something like min(set, lambda x: x.key), would this have to iterate through all elements?

🌐
GitHub
github.com › jitendrabhamare › Problems-vs-Algorithms › blob › master › Get_Min_Max.md
Problems-vs-Algorithms/Get_Min_Max.md at master · jitendrabhamare/Problems-vs-Algorithms
Do not use Python's inbuilt functions to find min and max. Is it possible to find the max and min in a single traversal? ... Traverse once through an array compare each element with min and max num. ... The code traverse through the list just once. Hence time complexity is O(n).
Author   jitendrabhamare
🌐
Quora
quora.com › What-is-the-time-complexity-of-finding-minimum-and-maximum-elements-from-an-unsorted-array-using-binary-search
What is the time complexity of finding minimum and maximum elements from an unsorted array using binary search? - Quora
The best case time complexity of binary search is Big-Omega(1). Then shouldn't we write the complexity of binary search as O(log n) instead of Big-Theta (log n) ? Why does everyone use O(log n)? How does one find the maximum and minimum values ...
🌐
UCI
ics.uci.edu › ~pattis › ICS-33 › lectures › complexitypython.txt
Complexity of Python Operations
The operations are organized by increasing complexity class Lists: Complexity Operation | Example | Class | Notes --------------+--------------+---------------+------------------------------- Index | l[i] | O(1) | Store | l[i] = 0 | O(1) | Length | len(l) | O(1) | Append | l.append(5) | O(1) | mostly: ICS-46 covers details Pop | l.pop() | O(1) | same as l.pop(-1), popping at end Clear | l.clear() | O(1) | similar to l = [] Slice | l[a:b] | O(b-a) | l[1:5]:O(l)/l[:]:O(len(l)-0)=O(N) Extend | l.extend(...)| O(len(...)) | depends only on len of extension Construction | list(...) | O(len(...)) | d
🌐
GitHub
github.com › python › cpython › issues › 92720
minmax function: (minitem, maxitem) in one pass · Issue #92720 · python/cpython
May 12, 2022 - # min(x), max(x) 295 ms ± 1.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) # minmax(x) 211 ms ± 2.41 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) # min(x, key = f), max(x, key = f) 1.22 s ± 2.07 ms per loop (mean ± ...
Published   May 12, 2022
Author   ghost