O(n) or O(n)^2 time complexity of the algorithm? [closed]

it is actually just O(n).. (not O(n+n), not O(2n), not O(n^n), just O(n) )
because since you increment j up to n in the inner loop
as soon as you finish the inner loop of n elements, the outer condition will be false.. so it will exit, after n iterations

Leave a Comment