This is my CPP solution.
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
ListNode* f = headA;
while(f!=NULL){
ListNode* s = headB;
while(s!=NULL){
if(f==s)
return s;
s = s->next;
}
f = f->next;
}
return NULL;
}
};