标签:alt 判断 next 相等 size bsp lis while 链表相交
思路:
两个链表相交,尾节点必然相等
int func(struct list *A , struct list *B)
{
struct list *pa = A;
struct list *pb = B;
while(pa != nullptr)
{
pa = pa->next;
}
while(pb != nullptr)
{
pb = pb->next;
}
return (pa->element == pb->element);
}
时间复杂度O(nlistA+nlistB)
标签:alt 判断 next 相等 size bsp lis while 链表相交
原文地址:https://www.cnblogs.com/achao123456/p/12158376.html