利用哈希表set()判断节点是否出现过

struct ListNode {
	int val;
	struct ListNode *next;
	ListNode(int x) :
			val(x), next(NULL) {
	}
};*/
class Solution {
public:
    ListNode* FindFirstCommonNode( ListNode* pHead1, ListNode* pHead2) {
        unordered_set<ListNode*> pH;
        ListNode *cur = pHead1;
        while(cur){
            pH.insert(cur);
            cur = cur->next;
        }
        cur = pHead2;
        while(cur){
            if(pH.find(cur) != pH.end()){
                return cur;
            }
            cur = cur->next;
        }
        
        return nullptr;
        
    }
};