Zero To DSAZero To DSA
Privacy Policy
Quadratic vs Linear

Constant vs Linear

easy
Time: O(n)
Space: O(1)

What is the time complexity of finding the maximum element in an unsorted array of size n?

Constraints

  • Write your answer in Big O notation.

Examples

Input: arr = [5, 2, 8, 1, 9]
Output: O(n)
You must examine every element to find the maximum.