Broadcom Interview Question

leetcode and the horse race problem