educative.io

I think the Example 2 quiz answer is wrong

n = 5  # n can be anything
sum = 0
for i in range(n):
    for j in range(n):
        sum += 1

print(sum)

We’re told the time complexity of this code is 5n​2+2n+4. Then we add sum = 0 to the outer loop. This adds n operations. So the solution should be 5n2+3n+4, not 5n2+4n+4.

I agree. This is what I have as well. The answer should be 5n^2+3n+4 , NOT 5n^2+4n+4.

Hi Ryan_Boehning, Daniel_Wu,

This is Anum from Educative.

This has been fixed.

We hope Educative has inspired to further your learning.

Best Regards,
Anum | Developer Advocate
educative.io

1 Like

Hi there, the answer is now different entirely. For example 2, the right answer is marked as 5n
^2+2n+4, not 5n^2+3n+4 as you agreed you would fix. This is affecting my understanding of the material, please explain. Thank you