Solution: Big (O) of Nested Loop With Addition
This review provides a detailed analysis of the time complexity of the Nested Loop with Addition problem!
We'll cover the following...
Solution
Node.js
const n = 10;const pie = 3.17;var sum = 0;for (var i = 1; i < n; i += 3) {console.log(pie);for (var j = 1; j < n; j += 2) {sum = sum + 1;console.log(sum);}}
On line 6 in the outer loop, var i=1; runs once, i<n; gets executed times and i+=3 executed ...
Ask