Create detect_n_removeloop.py#3670
Conversation
| # Driver program | ||
| llist = LinkedList() | ||
| llist.push(10) | ||
| llist.push(4) | ||
| llist.push(15) | ||
| llist.push(20) | ||
| llist.push(50) | ||
|
|
||
| # Create a loop for testing | ||
| llist.head.next.next.next.next.next = llist.head.next.next | ||
|
|
||
| llist.detectAndRemoveLoop() | ||
|
|
||
| print("Linked List after removing loop") | ||
| llist.printList() |
There was a problem hiding this comment.
| # Driver program | |
| llist = LinkedList() | |
| llist.push(10) | |
| llist.push(4) | |
| llist.push(15) | |
| llist.push(20) | |
| llist.push(50) | |
| # Create a loop for testing | |
| llist.head.next.next.next.next.next = llist.head.next.next | |
| llist.detectAndRemoveLoop() | |
| print("Linked List after removing loop") | |
| llist.printList() | |
| if __name__ == "__main__": | |
| # Driver program | |
| llist = LinkedList() | |
| llist.push(10) | |
| llist.push(4) | |
| llist.push(15) | |
| llist.push(20) | |
| llist.push(50) | |
| # Create a loop for testing | |
| llist.head.next.next.next.next.next = llist.head.next.next | |
| llist.detectAndRemoveLoop() | |
| print("Linked List after removing loop") | |
| llist.printList() |
You need to run test only when it is run as main and not every time it is imported
| self.next = None | ||
|
|
||
| class LinkedList: | ||
|
|
There was a problem hiding this comment.
possibly add a docstring describing about how to use and what does it do, comments are not able to show what is the soul purpose. docstring might help
|
Also the tests have failed, (you have checked that you know your pull request would not be merged if tests fail) |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions! |


Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.