Back to problems

Rank Songs by Popularity

Algorithm · Expedia · Medium

A music streaming service has collected preference data from several users about a set of songs. You are given n users and m songs, where each user i supplies an ordered list pref[i] that is a permutation of the song IDs from 0 to m - 1. Within any user's list, a song appearing earlier (at a smaller index) is favored over one appearing later. We define a dominance relationship between two songs: Song x beats song y if strictly more than half of the users rank x ahead of y,…

Checking your access…