SentinelOne interview question

Write a weighted random function.