• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594
            構(gòu)造一個針對單 1 #382
             2 #Runtime: 167 ms (Beats 33.87%)
             3 #Memory: 17.9 MB (Beats 11.29%)
             4 
             5 # Definition for singly-linked list.
             6 # class ListNode(object):
             7 #     def __init__(self, val=0, next=None):
             8 #         self.val = val
             9 #         self.next = next
            10 class Solution(object):
            11 
            12     def __init__(self, head):
            13         """
            14         :type head: Optional[ListNode]
            15         """
            16         self.head = head
            17         
            18 
            19     def getRandom(self):
            20         """
            21         :rtype: int
            22         """
            23         ans = self.head
            24         p = self.head
            25         cnt = 0
            26         while p:
            27             cnt += 1
            28             if random.randint(1, cnt) == 1:
            29                 ans = p.val
            30             p = p.next
            31         return ans
            32 
            33 # Your Solution object will be instantiated and called as such:
            34 # obj = Solution(head)
            35 # param_1 = obj.getRandom()鏈表的函數(shù),使之每次調(diào)用可以隨機輸出其中一個值
            參考了discussion的Reservoir sampling思路->https://leetcode.com/problems/linked-list-random-node/solutions/3278159/easy-solutions-in-java-python-and-c-look-at-once/


            久久婷婷国产剧情内射白浆 | 欧美精品一区二区精品久久| 久久精品国产亚洲AV嫖农村妇女| 久久久精品久久久久久| 亚洲中文久久精品无码| 国产精品久久久亚洲| 香蕉久久久久久狠狠色| 国产色综合久久无码有码| 天天爽天天狠久久久综合麻豆| 亚洲国产精品热久久| 77777亚洲午夜久久多喷| AA级片免费看视频久久| 中文字幕乱码久久午夜| 日韩美女18网站久久精品| 久久本道伊人久久| 亚洲国产婷婷香蕉久久久久久 | 久久99久久成人免费播放| 久久狠狠爱亚洲综合影院| 久久久久国产| 亚洲狠狠综合久久| 日韩欧美亚洲综合久久影院Ds| 丰满少妇高潮惨叫久久久| 久久精品国产2020| 欧美日韩精品久久久免费观看| 久久精品免费大片国产大片| 精品国际久久久久999波多野| 国产69精品久久久久久人妻精品| 久久久噜噜噜久久| 久久国产精品一区| 9191精品国产免费久久| 国产精品欧美久久久天天影视 | 很黄很污的网站久久mimi色| 亚洲国产精品久久66| 91精品国产91久久久久久| 99久久综合国产精品二区| 亚洲国产成人久久综合碰碰动漫3d | 国产精品嫩草影院久久| 亚洲狠狠久久综合一区77777| 国产高潮国产高潮久久久91| 久久精品免费观看| 久久精品亚洲男人的天堂|