GoLang Solution For LeetCode Problem: Random Pick with Weight
Solving Random Pick with Weight in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.
Problem Description
Note:
1 <= w.length <= 10000
1 <= w[i] <= 10^5
Example 1:
Input:
["Solution","pickIndex"]
[[[1]],[]]
Output: [null,0]
Example 2:
Input:
["Solution","pickIndex","pickIndex","pickIndex","pickIndex","pickIndex"]
[[[1,3]],[],[],[],[],[]]
Output: [null,0,1,1,1,0]
Explanation of Input Syntax:
- 1 <= w.length <= 10000
- 1 <= w[i] <= 10^5
See the full details of the problem Random Pick with Weight at LeetCode
Originally posted at: @github.com/halfrost/LeetCode-Go
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.