LeetCode - 160. Intersection of Two Linked Lists
来源:互联网 发布:mac中如何新建文件夹 编辑:程序博客网 时间:2024/06/05 00:15
代码如下:
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { if(headA == null || headB == null) return null; ListNode a = headA; ListNode b = headB; while(a != b){ a = (a == null)? headB : a.next; b = (b == null)? headA : b.next; } return a; }}
1. 注意这种traverse到end然后转换linked list的方法
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
- [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
- 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
- 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
- leetcode 160. Intersection of Two Linked Lists
- 160.[Leetcode]Intersection of Two Linked Lists
- CodeForces598ATric(数学,求和)
- 初识压缩感知 compressive sensing
- Android中短信发送与接受
- H5调用摄像头
- 完整AdaBoost算法
- LeetCode - 160. Intersection of Two Linked Lists
- cocos creater阅读笔记
- 康康准备了 M 斤的食物, 准备跟舍长交换哲学之宝 ♂
- javascript中defer的作用
- 数据库事务的四个基本性质(ACID)?
- While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was n
- Nginx 在 Windows 平台上编译
- It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea
- 辨异 —— 字母相近、含义差别很大的词组