Implement a referral leaderboard generator for a referral program. In this program, when a user refers a new user, they automatically become responsible for all users in the subsequent referral chain. Given two arrays—referrers representing the referrers (in the order they referred) and referrals representing the corresponding new users, build a leaderboard that lists the top three referrers along with their cumulative referral counts. A user's referral count includes all direct and indirect referrals down their chain.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected