【每日一题】LeetCode 160相交链表TypeScript
·


TypeScript
function getIntersectionNode(headA: ListNode | null, headB: ListNode | null): ListNode | null {
let set =new Set<ListNode>()
let cur = headA
while(cur){
set.add(cur)
cur=cur.next
}
let curB = headB
while(curB){
if(set.has(curB)){
return curB
}
curB = curB.next
}
return null
};
更多推荐
所有评论(0)