Implement a movie rental system with the following operations: 1) search(movie_id): Returns the 5 cheapest channel IDs for the specified unrented movie. 2) rent(movie_id, channel_id): Marks the movie as rented from the specified channel, so it will no longer appear in future search results for that movie. The system should handle a vector of vectors containing movie ID, channel ID, and price information.
Leetcode 1912. Design Movie Rental System
Maintain dynamic collections to (1) return the cheapest up-to-5 shops that have an unrented copy of a given movie and (2) report the cheapest up-to-5 currently rented movies, while supporting rent/drop operations that move items between those collections. The challenge is to handle frequent updates and top-k queries efficiently using ordered data structures keyed by price and the specified tie-breakers (shop, movie).
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Materiais associados
Nenhum anexo público associado a esta pergunta.
Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.
Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.