As reported: Rippling SDE-2 rounds: onsite round 1 (coding + design, India 2025, offer) and a pre-screen on HackerRank in Java (Mar 2025, rejected). Design a music analytics system: the most played songs, counted by unique users —
add_song(songId),play_song(userId, songId),print_analytics(); then the recently played unique songs —print_recently_played(userId)(the 3 most recent) andprint_recently_played(userId, k). Missing the word "unique" in part 2 is an easy slip the interviewer will point out. A third part exists but was not reached in 55 minutes for two parts. On HackerRank, generics in aPriorityQueuewere awkward and the interviewer preferred a plain sort over Java 8 streams.
Design MusicAnalytics:
addSong(songId)— add a song to the catalogue.playSong(userId, songId)— the user played the song.getAnalytics()— every song in the catalogue, ordered by the number of distinct users who have played it (most first); ties by smaller song id. Songs nobody played are included.getRecentlyPlayed(userId, k)— the user'skmost recently played distinct songs, most recent first (fewer if they played fewer).
Example
addSong(1); addSong(2); addSong(3)
playSong(10, 1); playSong(11, 1); playSong(10, 1)
playSong(10, 2)
playSong(12, 3); playSong(12, 3); playSong(12, 3)
getAnalytics() → [1, 2, 3] (song 1: users 10 and 11; songs 2 and 3: one user each)
playSong(10, 3)
getRecentlyPlayed(10, 3) → [3, 2, 1]
getRecentlyPlayed(12, 3) → [3] (song 3 three times is one distinct song)
Constraints: at most 10^5 calls; at most 5000 songs and at most 200 calls to getAnalytics; ids are integers in [1, 10^6]; playSong only names added songs; 1 ≤ k ≤ 100.
Code runner format: one call per line — ADD songId, PLAY userId songId, ANALYTICS, RECENT userId k — and the harness prints each returned list as [a,b,…]. Implement the class with the four methods (in Go: NewMusicAnalytics() and exported method names).