LeetCode 141.鏈表判環, LeetCode 142.並找出環的入口

判環利用快慢指針,若快指針遍歷完鏈表以前快慢指針沒有相遇的話,則說明鏈表中有環。web 代碼:svg /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Sol
相關文章
相關標籤/搜索