Initialization values are different in the loops

At the challenge 1 which is previous page of solution review, the initialization value was ‘1’ of variable ‘var’ and ‘j’ in the outer and inner loops.
But It changes to ‘0’ at the solution review page.
would be the time complexity still same even if the initialization value is different?

Course: Algorithms for Coding Interviews in Java - Learn Interactively
Lesson: Solution Review: Big O of a Nested Loop with Addition - Algorithms for Coding Interviews in Java

Hi @Jin,
Thanks for pointing that out. I am forwarding this to the relevant team and this will be updated.

In this case, the time complexity, in terms of big O notation, will be the same on initializing it with 0 or 1. The n or n-1 steps are represented as O(n). However, it should be initialized with the same value in Solution as well as the Challenge. It will be fixed soon.

If you are not convinced, please let us know. Thanks!

1 Like