Can someone please help me understand why is the time complexity O(n^3) shouldn’t it be O(n^2)? Why creating subarrays takes O(n^2)?
Because we are adding element at 0 index in templist which is array. So making place at first will need O(n) time.
But here tempList is LinkedList.
Shouldn’t it be O(1) to add item to first place in LinkedList?
With LinkedList the tc does seem to be N^2, please correct if not so.
@admin with LinkedList the time complexity does seem to be O(n^2).
Please add this point to the solution.
have the same question. Thanks for raising it!