Zero To DSAZero To DSA
Privacy Policy·Support on Ko‑fi
Quadratic vs Linear

Constant vs Linear

easy

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.