Skip to content

Commit dff26b3

Browse files
authored
Add files via upload
1 parent 95767fb commit dff26b3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Intersection_of_Two_LL.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
4+
ListNode* a = headA, *b = headB;
5+
while(a != b){
6+
if(a == NULL){
7+
a = headB;
8+
}
9+
else{
10+
a = a -> next;
11+
}
12+
13+
if(b == NULL){
14+
b = headA;
15+
}
16+
else{
17+
b = b -> next;
18+
}
19+
}
20+
return a;
21+
}
22+
};

0 commit comments

Comments
 (0)