标签:alt ima png hashmap next cti ret tin adb
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
// 最容易想到的是hashmap
// 双指针法
public class Solution {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
if(headA == null || headB == null) return null;
ListNode pA = headA; ListNode pB = headB;
while(pA != pB){
pA = pA == null? headB:pA.next;
pB = pB == null? headA:pB.next;
}
return pA;
}
}
标签:alt ima png hashmap next cti ret tin adb
原文地址:https://www.cnblogs.com/athony/p/13060048.html