logo

Crowdly

What is the worst-case time complexity of this function? Make sure you define...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

What is the worst-case time complexity of this function?

Make sure you define any variables you use and you can ignore the cost of comparison. (no explanation, no marks)

def func(arr: List[int], target: int) -> List[int]:

    n = len(arr)

    for i in range(n - 1):

        for j in range(i + 1, n):

            if arr[i] + arr[j] == target:

                return [i, j]

    return []

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!