Robinhood | L2 | New York | Dec-2021 [Reject]
Anonymous User
3723
Jan 19, 2022
Jan 20, 2022

For onsite, I was asked an algorithms question similar to this:

Users can refer each other to Robinhood. We want keep track of who is responsible for the most referrals and display the top users on a leaderboard.

If user A refers user B, and user B refers user C. Then the leaderboard looks like this:

User A: 2 Referrals
User B: 1 Referrals
User C: 0 Referrals

Explanation: User B has 1 referral for referring user C. User A has 2 referrals because they referred user B, and they also inherit the referral for user C since user B is one of their referrals.

Given a list of referrals (Example Input: [ ["A","B"] , ["B", "C"] ], write a function that determines the leaderboard order.

Comments (4)