/*求出两个链表的长度,并且跳过长的链表部分,然后开始比较是否相等。/
public static ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
if (pHead1==null||pHead2==null){
return null;
}
int length1 = getLength(pHead1);
int length2 = getLength(pHead2);
while (length1<length2){
pHead2 = pHead2.next;
length2--;
}
while (length1>length2){
pHead1 = pHead1.next;
length1--;
}
while (pHead1!=null&&pHead1.val!= pHead2.val){
pHead1 = pHead1.next;
pHead2 = pHead2.next;
}
return pHead1;
}
public static int getLength(ListNode head){
if (head==null){
return 0;
}
ListNode p = head;
int count = 0;
while (p!=null){
count++;
p = p.next;
}
return count;
}