-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Contains loops.py add #2442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contains loops.py add #2442
Conversation
syncing from upstream repo
…rue if one is found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need at least two doctests. One that returns True and one that returns False. We need to defined what a loop is. Is a loop just the same value twice in a row? Would 1, 2, 1, 2 be a loop?
@@ -13,8 +13,25 @@ def __init__(self, data: Any) -> None: | |||
|
|||
def contains_loop(root: Node) -> bool: | |||
""" | |||
given a node, returns true if linked list contains a loop | |||
A linked list contains a loop when traversing through a loop, no null is reached. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This explanation is still unclear to me. What is a null in this context?
Hey @kanthuc, TravisCI finished with status TravisBuddy Request Identifier: 500c6ff0-f9e9-11ea-8549-e58e00c6eb1f |
Hey @kanthuc, TravisCI finished with status TravisBuddy Request Identifier: 04efb2f0-f9eb-11ea-8549-e58e00c6eb1f |
Travis tests have failedHey @kanthuc, TravisBuddy Request Identifier: dde3b520-f9eb-11ea-8549-e58e00c6eb1f |
Travis tests have failedHey @kanthuc, TravisBuddy Request Identifier: bffc4d90-f9ed-11ea-8549-e58e00c6eb1f |
Hey @kanthuc, TravisCI finished with status TravisBuddy Request Identifier: c80f7e60-f9ef-11ea-8549-e58e00c6eb1f |
* added an algorithm which checks a linked list for loops and returns true if one is found * added doctests and clarified meaning of loop * Define Node.__iter__() * Update and rename has_loop.py to has_duplicate_data.py * Update has_duplicate_data.py * Update has_duplicate_data.py * Update and rename has_duplicate_data.py to has_loop.py * Update has_loop.py Co-authored-by: Christian Clauss <cclauss@me.com>
Describe your change:
Added an algorithm which checks a linked list for loops and returns true if one is found.
Checklist:
Fixes: #{$ISSUE_NO}
.