educative.io

Educative

Runtime Complexity

Isn’t the runtime of the constructor O(N * logN) and wouldn’t this be our concern? Or is it because we are only running the ‘add’ function in the test cases that we concern ourselves with it’s runtime?

I believe the time complexity of constructor would be O(N*logK). logK for doing an add and call add N times for all the numbers in the constructor.