###### tags: `leetcode`
# Question No.160:
### Description:
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:

begin to intersect at node c1.
Given a pattern and a string s, find if s follows the same pattern.
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s.
### Solution:
Use **_ordered_set_** to store already exist items
### AC code
```cpp=
/*struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};*/
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
if(headA==NULL || headB==NULL)
return NULL;
unordered_set<ListNode* > A;
ListNode *taila;
ListNode *tailb;
taila = headA;
tailb = headB;
while(taila!=NULL){
A.insert(taila);
taila = taila->next;
}
while(tailb!=NULL){
if(A.find(tailb)!=A.end()){
return tailb;
}
tailb = tailb->next;
}
return NULL;
}
};
```