1. public Node firstCommonNode(Node a, Node b){
    2. Node l1 = a;
    3. Node l2 = b;
    4. while(l1 != l2){
    5. l1 = (l1 == null) ? b : l1.next;
    6. l2 = (l2 == null) ? a : l2.next;
    7. }
    8. return l1;
    9. }

    链表公共节点.PNG