You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While getting the length of the linked list, code will take O(n) of unnecessary time as it executes - len(tuple(iter(self)))
This also takes up O(n) of extra space as it is creating a tuple first.
This can be easily avoided by maintaining an instance variable len, increment/decrement it while inserting/deleting elements.