← Questions

Top K similar movies from a similarity graph

0
GoogleCodingLast asked Dec 2025

Movies are nodes with a rating, and an edge links two similar movies; similarity carries across edges. Given a movie and k, return the k highest-rated movies reachable from it, not counting the movie itself. Traverse with BFS and keep the best k in a heap. Follow-up: what problems would this have in production, and how would caching help?

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding