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
相关文章
相关标签/搜索