
random
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 528. Random Pick with Weight
Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight.Note:1 <= w.length <= 1...原创 2019-09-10 10:03:31 · 146 阅读 · 0 评论 -
晨哥Leetcode Reservoir sampling题目:Random Pick Index,Linked List Random Node
Reservoir sampling 蓄水池抽样适用于我们不知道符合条件的数据集有多大的情况有一些面试题是这一类的:可否在一未知大小的集合中,随机取出一元素?。或者是Google面试题: I have a linked list of numbers of length N. N is very large and I don’t know in advance the exact value...原创 2019-09-10 10:53:55 · 128 阅读 · 0 评论 -
晨哥Leetcode 384. Shuffle an Array
Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);// Shuffle the array [1,2,3] and return its ...原创 2019-09-11 06:34:01 · 93 阅读 · 0 评论 -
晨哥Leetcode 497. Random Point in Non-overlapping Rectangles
Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space covered by the rectangles.Note:An integer poin...原创 2019-09-11 07:29:20 · 232 阅读 · 0 评论