Zero To DSAZero To DSA
Privacy Policy路FAQ路Report a Bug路Support on Ko鈥慺i
Quadratic vs Linear

Constant vs Linear

easy

What is the time complexity (excluding input) of this function?

C#C#
int FindMax(int[] arr) {
    int max = arr[0];
    foreach (var x in arr)
        if (x > max) max = x;
    return max;
}

Constraints

  • Write your answer in Big O notation.

Examples

Input: arr = [5, 2, 8, 1, 9]