Skip to content

Practice Design Movie Rental System

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1912
LeetCode Problem

Design Movie Rental System

Problem Statement

MovieRentingSystem(n,entries) stores [shop,movie,price] copies, at most one per shop/movie. search(movie) lists up to five unrented shops ordered by price then shop ID. rent(shop,movie) rents an available copy; drop returns it. report() lists up to five rented [shop,movie] pairs ordered by price, shop ID, then movie ID. All orderings are ascending; rent/drop calls are valid. Practice approach: Maintain available copies in per-movie ordered sets and rented copies in one global ordered set, with a price lookup per copy. Move entries atomically between sets. Include all tie-breaking fields so equal prices do not collapse distinct copies.

Source: Design Movie Rental System on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
["MovieRentingSystem","search","rent","rent","report","drop","search"]
[[3,[[0,4,6],[1,4,5],[2,4,5],[0,7,5]]],[4],[2,4],[0,7],[],[2,4],[4]]
Output
[null,[1,2,0],null,null,[[0,7],[2,4]],null,[1,2,0]]
Explanation

Search breaks equal-price ties by shop. The report also ranks shop 0 before shop 2 at equal price; dropping restores shop 2 to availability.

Constraints

1 <= n <= 3 * 10^5
1 <= entries.length <= 10^5
0 <= shop < n; 1 <= movie, price <= 10^4
At most 10^5 total method calls.

Related LeetCode Problems

Practice more problems similar to Design Movie Rental System.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.