求兩個鏈表的交點(C++)

方法一:利用C++的set容器求交集 思路 將鏈表A的元素放入到set集合中 遍歷鏈表B,若是鏈表B的某個結點在set集合中,返回該節點 代碼實現 struct ListNode { int val; ListNode* next; ListNode(int x) :val(x), next(NULL) {} }; class Solution1//用set容器求解 { public:
相關文章
相關標籤/搜索