LinkedIn Interview Question

Similar to leetcode 528, random pick with weight