FastPrepReferral Credits After a First Song
Problems/Referral Credits After a First Song

Referral Credits After a First Song

Suno logoSuno● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A Suno Glassdoor interview question dated September 13, 2026 specifies 100 credits to referrer and referee on the referee's first song, a 300-credit referral cap, and the published example. Earliest-referral resolution and sorted output are declared deterministic adapters.

Each referral row [referrer, referredUser] records an invitation. If a user appears as the referred user more than once, only their earliest row is valid. Process creators in order; the first time a referred user creates a song, they receive 100 credits and their valid referrer receives 100 credits.

A referrer can receive credits for at most three referred users, while a referred user's own 100-credit award is unaffected by that cap. Later songs by the same user award nothing. Return [userId, credits] rows for users with positive credits, sorted by user ID.

Function

referralSongCredits(referrals: int[][], creators: int[]) → int[][]

Examples

Example 1

referrals = [[1,2],[1,3],[2,3],[2,5],[3,9]]creators = [2,2,4,2,3,5,8]return = [[1,200],[2,200],[3,100],[5,100]]

Only the first invitation for user 3 is valid; first songs by users 2, 3, and 5 produce the shown balances.

Example 2

referrals = [[10,20]]creators = [20,20]return = [[10,100],[20,100]]

The repeated song event does not issue a second award.

Constraints

  • 0 <= referrals.length, creators.length <= 100000
  • User IDs are positive integers.

More Suno problems

  • Longest Path in a Directed Acyclic GraphPHONE SCREEN
See Suno hiring insights
Saved
class Solution {
    public int[][] referralSongCredits(int[][] referrals, int[] creators) {
      // Write your code here.
    }

}
Checking account…