SentinelOne Interview Question

Write a weighted random function.