class Solution {
public:
ListNode *getIntersectionNode(ListNode *x, ListNode *y) {
if(!x||!y) return NULL;
ListNode *xx=x,*yy=y;
while(xx!=yy){
xx=(xx?xx->next:y);
yy=(yy?yy->next:x);
}
return xx;
}
};
leetcode 160. 相交链表 唔~
最新推荐文章于 2024-05-02 17:55:52 发布