-
Notifications
You must be signed in to change notification settings - Fork 108
all tests passed #98
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
base: main
Are you sure you want to change the base?
all tests passed #98
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,4 +11,11 @@ def intersection_node(headA, headB): | |||||||||||||||||
| """ Will return the node at which the two lists intersect. | ||||||||||||||||||
| If the two linked lists have no intersection at all, return None. | ||||||||||||||||||
| """ | ||||||||||||||||||
| pass | ||||||||||||||||||
| if not headA or not headB: | ||||||||||||||||||
| return None | ||||||||||||||||||
| p1, p2 = headA, headB | ||||||||||||||||||
| while p1.val!= p2.val: | ||||||||||||||||||
| p1 = p1.next if p1.next else headB | ||||||||||||||||||
| p2 = p2.next if p2.next else headA | ||||||||||||||||||
|
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your current code causes an infinite loop in some cases. When you set Try using the debugger on test case 4
Suggested change
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| return p1 | ||||||||||||||||||
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 want to compare the node objects and not just their values. Two nodes can have the same values but be different objects in memory!