LinkedIn interview question

Similar to leetcode 528, random pick with weight