Problem:
思路:
Solution (C++):
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
using L = ListNode*;
L a = headA, b = headB;
while (a) {
while (b) {
if (a == b) return a;
else b = b->next;
}
if (b == NULL) { b = headB; a = a->next; }
}
return NULL;
}
性能:
Runtime: 932 ms Memory Usage: 14.8 MB
思路:
Solution (C++):
性能:
Runtime: ms Memory Usage: MB