160. Intersection of Two Linked Lists
来源:互联网 发布:广告牌制作软件手机 编辑:程序博客网 时间:2024/06/06 06:11
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { int na = 0, nb = 0; ListNode *headAA = headA; ListNode *headBB = headB; while (headAA) { headAA = headAA->next; na++; } while (headBB) { headBB = headBB->next; nb++; } int n = na -nb; if (na > nb) { while (n--) { headA = headA->next; } } else if(nb>na){ n = -n; while (n--) { headB = headB->next; } } while (headA != headB) { headA = headA->next; headB = headB->next; } return headA;}
0 0
- [LeetCode]160.Intersection of Two Linked Lists
- LeetCode 160. Intersection of Two Linked Lists
- 【LeetCode】160.Intersection of Two Linked Lists
- [leetcode] 160.Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- [LeetCode]160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- LeetCode--160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- LeetCode 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 【LeetCode】160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 160. Intersection of Two Linked Lists
- 图解堆算法、链表、栈与队列
- 每周数据结构【4】递归算法:把B树的所有左右节点进行交换
- ACM--二叉树-已知前中序求后序--POJ-2255
- 在java中,final,finally,fanalize的区别
- 关于android开发时在v7包下无法加载recyclerview的问题
- 160. Intersection of Two Linked Lists
- IOC的概念
- 数据库操作语言有哪两大部分功能
- 类模板定义和实现问题
- phyton从1加到100
- 项目2—本月有几天
- 51nod--1072 威佐夫游戏 (博弈论)
- 破解Unity3D的步骤-为部分人提供帮助
- adb操作命令详解及大全