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
I'm not sure this is necessarily an issue: The current solution of linked_list_challenge.ipynb uses an iterative approach to getting the length of a linked list, resulting in an O(n) time complexity for that method. Another solution could be to have an instance variable, updating this variable whenever we insert_to_front(), append(), or delete() and return this variable whenever we call the length method (thus O(1)) . I'm not a python expert, so I don't know how "Pythonic" this solution is, but I got it working in my notebook and can submit a PR if this is appropriate
The text was updated successfully, but these errors were encountered:
Yeah, I thought about that too. Though I'm also not a Python expert, I've seen a similar solution in the book "Data Structures and Algorithms in Python" by Goodrich et al.
I'm not sure this is necessarily an issue: The current solution of linked_list_challenge.ipynb uses an iterative approach to getting the length of a linked list, resulting in an O(n) time complexity for that method. Another solution could be to have an instance variable, updating this variable whenever we insert_to_front(), append(), or delete() and return this variable whenever we call the length method (thus O(1)) . I'm not a python expert, so I don't know how "Pythonic" this solution is, but I got it working in my notebook and can submit a PR if this is appropriate
The text was updated successfully, but these errors were encountered: