1 /* 2 public class ListNode { 3 int val; 4 ListNode next = null; 5 6 ListNode(int val) { 7 this.val = val; 8 } 9 }*/ 10 public class Solution { 11 public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) { 12 ListNode temp1 = pHead1; 13 ListNode temp2 = pHead2; 14 while(temp1 != temp2) { 15 temp1 = (temp1 == null) ? pHead2 : temp1.next; 16 temp2 = (temp2 == null) ? pHead1 : temp2.next; 17 } 18 return temp1; 19 } 20 }
标签:10,ListNode,val,相交,链表,temp2,temp1,null From: https://www.cnblogs.com/StringBuilder/p/17839854.html