int listLength(Node* L) {
int count = 0;
for (Node* p = L->next; p != NULL; p = p->next)
count++;
return count;
}
Node* commonNode(Node* L1, Node* L2) {
int len1 = listLength(L1);
int len2 = listLength(L2);
Node* p = L1->next, * q = L2->next;
int i;
for (i = len1; i > len2; i--) p = p->next;
for (i = len2; i > len1; i--) q = q->next;
for (; p != NULL && q != NULL && p != q; p = p->next, q = q->next) ;
return p;
}