/* public class ListNode { public int val; public ListNode next; public ListNode (int x) { val = x; } }*/ class Solution { public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) { ListNode pa = pHead1; ListNode pb = pHead2; if (pa == null || pb == null) return null; int times = 0; while (true) { if (pa == pb) return pa; pa = pa.next; pb = pb.next; if (pa == null) { if (times == 2) return null; pa = pHead2; times++; } if (pb == null) { if (times == 2) return null; pb = pHead1; times++; } } } }