The final step in most recommender systems is selecting the top-K items to present to a user. Given predicted scores for all items and a set of items the user has already rated, the system must return the K highest-scoring items that the user has not yet seen.
Given a list of predicted scores (one per item), a collection of already-rated item indices, and a count K, return the indices of the top-K unrated items sorted by descending score.
Return at most k unrated indices ordered by descending score; break ties by smaller index.
Input: scores = [3.5, 1.2, 4.8, 2.1, 5.0], rated_indices = [0, 2], k = 2
Output: [4, 3]
Explanation: After removing items 0 and 2, items 4 and 3 have the two highest scores.
Input: scores = [1.0, 3.0, 2.0], rated_indices = [], k = 2
Output: [1, 2]
Build score-index pairs only for indices absent from rated_indices.
Sort by negative score and then index before taking the first k pairs.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
The final step in most recommender systems is selecting the top-K items to present to a user. Given predicted scores for all items and a set of items the user has already rated, the system must return the K highest-scoring items that the user has not yet seen.
Given a list of predicted scores (one per item), a collection of already-rated item indices, and a count K, return the indices of the top-K unrated items sorted by descending score.
Return at most k unrated indices ordered by descending score; break ties by smaller index.
Input: scores = [3.5, 1.2, 4.8, 2.1, 5.0], rated_indices = [0, 2], k = 2
Output: [4, 3]
Explanation: After removing items 0 and 2, items 4 and 3 have the two highest scores.
Input: scores = [1.0, 3.0, 2.0], rated_indices = [], k = 2
Output: [1, 2]
Build score-index pairs only for indices absent from rated_indices.
Sort by negative score and then index before taking the first k pairs.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number