Top-Rated Similar Movies
Problem statement
There are n movies with IDs 0 through n - 1. Movie i has rating ratings[i] and a list similar[i] of movie IDs. Given a starting movie start and an integer k, return the IDs of the highest-rated eligible movies.
The problem statement continues
ProExamples
Example 1
ratings = [60,80,95,95,100]similar = [[1,2],[3],[],[],[]]start = 0k = 2return = [2,3]Movies 1, 2, 3 are reachable. Movies 2 and 3 tie at rating 95, so their IDs appear in ascending order. Movie 4 is unreachable despite its higher rating.
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week