Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update 面试题02.07.链表相交.md #2955

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

Open
lanzilan827 wants to merge 1 commit into youngyangyang04:master
base: master
Choose a base branch
Loading
from lanzilan827:master

Conversation

Copy link

@lanzilan827 lanzilan827 commented Jul 9, 2025

在 Python 中,curA == curB 和 curA is curB 是两个不同的操作:

== 比较的是两个对象的值是否相等(调用 eq() 方法)。

is 比较的是两个对象的身份是否相同(即是否指向内存中的同一个对象)。

在这个链表相交的问题中,我们是想找两个链表在内存中首次相交的节点,所以判断的是:是否是同一个节点对象,而不是值是否相同。值相同并不代表是同一个节点。

在 Python 中,curA == curB 和 curA is curB 是两个不同的操作:
== 比较的是两个对象的值是否相等(调用 __eq__() 方法)。
is 比较的是两个对象的身份是否相同(即是否指向内存中的同一个对象)。
在这个链表相交的问题中,我们是想找两个链表在内存中首次相交的节点,所以判断的是:是否是同一个节点对象,而不是值是否相同。值相同并不代表是同一个节点。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /