Design Movie Rental System
expert · 1145 · lc hard +32 · 62.5% accepted · 548 likes · top 64%
Description
You operate a movie rental service across n shops. Each entry entries[i] = [shopi, moviei, pricei] means shop shopi stocks movie moviei at pricei.
Implement MovieRentingSystem:
- MovieRentingSystem(int n, int[][] entries) — Initializes the system.
- List<Integer> search(int movie) — Returns up to 5 shops with the cheapest unrented copy of movie (sort by price asc, then shop ID asc).
- void rent(int shop, int movie) — Marks the copy rented.
- void drop(int shop, int movie) — Returns the copy.
- List<List<Integer>> report() — Returns up to 5 cheapest currently rented copies as [shop, movie] (sort by price asc, then shop ID asc, then movie ID asc).
Example 1:
Example 2:
Code