LeetCode 141 环形链表

一:题目   二:解法 运用快慢指针,如果两指针相遇,则有环。 public class Solution { public boolean hasCycle(ListNode head) { ListNode slow=head; ListNode fast=head; while(fast!=null&&fast.next!=null){
相关文章
相关标签/搜索