Skip to content

Commit

Permalink
add #160
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtx0 committed Oct 23, 2023
1 parent de6996e commit 9044ab5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions leetcode/160.相交链表.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
struct ListNode *p = headA, *q = headB;

while (q)
{
while (p)
{
if (p -> val == q -> val)
{
if (p == q)
{
return p;
}
}
p = p -> next;
}
p = headA;
q = q -> next;
}

return NULL;
}

0 comments on commit 9044ab5

Please sign in to comment.