leetcode382】的更多相关文章

Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:What if the linked list is extremely large and its length is unknown to you? Could you solve this effic…
/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * } */ public class Solution { ListNode head; Random random; /** @param head The linked list's head. No…