class Solution { public: // 不断遍历链表2中所有结点, 与链表1中的每一个结点比较, 时间复杂度为O(n^2) ListNode* FindFirstCommonNode( ListNode* pHead1, ListNode* pHead2) { if(pHead1 == NULL || pHead2 == NULL) { return NULL; } ListNode* pCur1 = pHead1; ListNode* pCur2 = pHead2; while(pCur1 != NULL) { while(pCur2 != NULL) { if(pCur2 == pCur1) { return pCur2; } pCur2 = pCur2->next; } pCur2 = pHead2; pCur1 = pCur1->next; } return NULL; } };