I got asked this question in my FAANG ML round.
You have a list of pairwise ratings of videos from users. Not the exact rating number but just the comparison. For eg. A>B, B>C, C>D etc.
Build a recommendation algorithm to recommend videos in the order of highest to lowest ratings.
For the first part, assume there's just one user and ratings are transitive. Meaning, if A>B, B>C then A>C always holds true. Also there's no conflict, meaning if A>B then B>A is not possible in the input.
The first part is straightforward topo sort problem and the order of topo sort can be used as a list for recommendation.
But now, for the follow up question, both transitive and non-conflicting assumptions do not hold true.
E.g.:
User1 ratings: A>B, B>C, C>A
User 2 ratings: B>A, A>C
and so on.
How would you solve the follow up? You are free to use DSA + ML to solve the follow up.