剑指 Offer 52. 两个链表的第一个公共节点bahttps://leetcode.cn/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/
| 2023-8-7
0  |  阅读时长 0 分钟
Date
Aug 2, 2023
need_review
need_review
type
剑指 Offer(第 2 版)
undo
undo
难度
简单
 
输入两个链表,找出它们的第一个公共节点。
如下面的两个链表
notion image
在节点 c1 开始相交。
示例 1:
notion image
示例 2:
notion image
示例 3:
notion image
注意:
  • 如果两个链表没有交点,返回 null.
  • 在返回结果后,两个链表仍须保持原有的结构。
  • 可假定整个链表结构中没有循环。
  • 程序尽量满足 O(n) 时间复杂度,且仅用 O(1) 内存。

解法1
  • Giscus
目录