由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一道链表题及其变种
相关主题
面试面试官错了怎么办?北美点评网面经
F家电面有没有觉得这个面试问题有点膈应?
Lowest common ancestor of two nodes of Binary TreeAnother problem about Binary tree.
Lowest Common Ancestor of multiple nodes in a binary tree弱问:两个数组的并集和交集
发一道面试题分享一个链表相关的面试题
两个链表怎么查找相交点?non recursive binary tree traversal in O(n) time and O(1) space
问一个链表的问题请教LEETCODE讲解部分的LCA一道题的变种。。
How can one determine whether a singly linked list has a cycle?刚才看到小尾羊的一个面试题
相关话题的讨论汇总
话题: node话题: same话题: end话题: list话题: 相交
进入JobHunting版参与讨论
1 (共1页)
C***y
发帖数: 2546
1
两个singly linked list, 问如何判断是否相交,相交的话找出第一个相交的节点
变种:找binary tree中两个node 的lowest common ancestor,node有一个parent指针
g*********e
发帖数: 14401
2
my solution for 1:
if they intersect, they would end up in the same node, so just traverse to
the end and see if the two end node is the same.
If the same, then we can connect the end node to the start of the second
list( making it a circular list), then set two pointers from the start of
the first list, going at speed of 1 and 2 node per time. their first meet
would be the same distance from the intersect as the start position.
g*********e
发帖数: 14401
3
pro 2 is easy,
you just find the depth difference of the two nodes.
then proceed the node at lower level up to make them at the same level,
then check and go up together.
1 (共1页)
进入JobHunting版参与讨论
相关主题
刚才看到小尾羊的一个面试题发一道面试题
remove a node (and its memory) from a doubly linked list两个链表怎么查找相交点?
career cup上面一题递归求解问一个链表的问题
一道C面试题How can one determine whether a singly linked list has a cycle?
面试面试官错了怎么办?北美点评网面经
F家电面有没有觉得这个面试问题有点膈应?
Lowest common ancestor of two nodes of Binary TreeAnother problem about Binary tree.
Lowest Common Ancestor of multiple nodes in a binary tree弱问:两个数组的并集和交集
相关话题的讨论汇总
话题: node话题: same话题: end话题: list话题: 相交