@@ -0,0 +1,1444 @@
+# Definition for singly-linked list.%0A# class ListNode(object):%0A#     def __init__(self, x):%0A#         self.val = x%0A#         self.next = None%0A%0Aclass Solution(object):%0A%0A    def __init__(self, head):%0A        %22%22%22%0A        @param head The linked list's head.%0A        Note that the head is guaranteed to be not null, so it contains at least one node.%0A        :type head: ListNode%0A        %22%22%22%0A        self.head  = head%0A        self.count = 0%0A        %0A        slow = head%0A        fast = head%0A        %0A        while fast != None and fast.next != None:%0A            self.count += 1%0A            %0A            slow = slow.next%0A            fast = fast.next.next%0A        else:%0A            self.count *= 2%0A            %0A            if fast != None:%0A                self.count += 1%0A                %0A        self.mid = slow%0A        %0A%0A    def getRandom(self):%0A        %22%22%22%0A        Returns a random node's value.%0A        :rtype: int%0A        %22%22%22%0A        %0A        import random%0A        %0A        rand = random.randint(0, self.count - 1)%0A                %0A        if rand %3C self.count // 2:%0A            begin = 0%0A            node  = self.head%0A        else:%0A            begin = self.count // 2%0A            node  = self.mid%0A            %0A        for _ in xrange(begin, rand):%0A            node = node.next%0A            %0A        return node.val%0A        %0A        %0A# Your Solution object will be instantiated and called as such:%0A# obj = Solution(head)%0A# param_1 = obj.getRandom()%0A

Create solution.py