Intersection of Two Linked Lists
2015-07-19 18:45
246 查看
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
begin to intersect at node c1.
Notes:
If the two linked lists have no intersection at all, return
The linked lists must retain their original structure after the function returns.
You may assume there are no cycles anywhere in the entire linked structure.
Your code should preferably run in O(n) time and use only O(1) memory.
Credits:
Special thanks to @stellari for adding this problem and creating all test cases.
暴力算法 直接了当
对A链表每一个元素 遍历一遍B链表的元素 如果两个元素相等 则找出相交的链表
For example, the following two linked lists:
A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3
begin to intersect at node c1.
Notes:
If the two linked lists have no intersection at all, return
null.
The linked lists must retain their original structure after the function returns.
You may assume there are no cycles anywhere in the entire linked structure.
Your code should preferably run in O(n) time and use only O(1) memory.
Credits:
Special thanks to @stellari for adding this problem and creating all test cases.
暴力算法 直接了当
对A链表每一个元素 遍历一遍B链表的元素 如果两个元素相等 则找出相交的链表
相关文章推荐
- word2010表格中的内容怎么设置行距
- ACM暑期计划——第四天
- 使用xml.etree.ElementTree遍历xml所有节点
- 《开源分享1》:前端开发必备《Html-CSS中文手册》
- java多线程之停止线程
- 查找---BF算法(1)
- POJ-1247
- mysql的日志管理
- 循环06~~~10
- 深入Android【八】 —— Activity间数据传输
- linux内核模块相关命令:lsmod,depmod,modprobe,modinfo,insmod,rmmod 使用说明
- SVGEditor
- Android序列化
- android APP性能数据收集
- Eclipse JSP乱码
- 股票学习30(公司财务分析01)
- 【ci框架】ci框架中中有关redis文件缓存相关的文件
- 如何知道一个python对象的类型?
- 黑马程序员_笔记总结(给自己看的向)
- 12天学好C语言——记录我的C语言学习之路(Day 3)