python-ds
python-ds copied to clipboard
adding an edge case missed in linked list remove_nth_node_from_end.py
Case when the length of the linked list and N is equal
Description
In the Linked List Problem of Removing nth Node from the End, One of the cases was missed where the length of the linked list is equal to n, In this case, the current code throws AttributeError: 'NoneType' object has no attribute 'next'
Fixes # (issue)
- Adding an extra node in front
- Return value from function remove was not assigned to head
Type of change
- [*] Bug fix (non-breaking change which fixes an issue)