题目:

题解:
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
class Solution(object):
    def detectCycle(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        a=head
        i=0
        dic={}
        while a:
            if a in dic:
                return a
            dic[a]=i
            i+=1
            a=a.next
        return None
                


















