{ "data": { "question": { "questionId": "2023", "questionFrontendId": "1912", "categoryTitle": "Algorithms", "boundTopicId": 842261, "title": "Design Movie Rental System", "titleSlug": "design-movie-rental-system", "content": "

You have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning movies. The system should also support generating a report of the currently rented movies.

\r\n\r\n

Each movie is given as a 2D integer array entries where entries[i] = [shopi, moviei, pricei] indicates that there is a copy of movie moviei at shop shopi with a rental price of pricei. Each shop carries at most one copy of a movie moviei.

\r\n\r\n

The system should support the following functions:

\r\n\r\n\r\n\r\n

Implement the MovieRentingSystem class:

\r\n\r\n\r\n\r\n

Note: The test cases will be generated such that rent will only be called if the shop has an unrented copy of the movie, and drop will only be called if the shop had previously rented out the movie.

\r\n\r\n

 

\r\n

Example 1:

\r\n\r\n
\r\nInput\r\n["MovieRentingSystem", "search", "rent", "rent", "report", "drop", "search"]\r\n[[3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]], [1], [0, 1], [1, 2], [], [1, 2], [2]]\r\nOutput\r\n[null, [1, 0, 2], null, null, [[0, 1], [1, 2]], null, [0, 1]]\r\n\r\nExplanation\r\nMovieRentingSystem movieRentingSystem = new MovieRentingSystem(3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]);\r\nmovieRentingSystem.search(1);  // return [1, 0, 2], Movies of ID 1 are unrented at shops 1, 0, and 2. Shop 1 is cheapest; shop 0 and 2 are the same price, so order by shop number.\r\nmovieRentingSystem.rent(0, 1); // Rent movie 1 from shop 0. Unrented movies at shop 0 are now [2,3].\r\nmovieRentingSystem.rent(1, 2); // Rent movie 2 from shop 1. Unrented movies at shop 1 are now [1].\r\nmovieRentingSystem.report();   // return [[0, 1], [1, 2]]. Movie 1 from shop 0 is cheapest, followed by movie 2 from shop 1.\r\nmovieRentingSystem.drop(1, 2); // Drop off movie 2 at shop 1. Unrented movies at shop 1 are now [1,2].\r\nmovieRentingSystem.search(2);  // return [0, 1]. Movies of ID 2 are unrented at shops 0 and 1. Shop 0 is cheapest, followed by shop 1.\r\n
\r\n\r\n

 

\r\n

Constraints:

\r\n\r\n", "translatedTitle": "设计电影租借系统", "translatedContent": "

你有一个电影租借公司和 n 个电影商店。你想要实现一个电影租借系统,它支持查询、预订和返还电影的操作。同时系统还能生成一份当前被借出电影的报告。

\n\n

所有电影用二维整数数组 entries 表示,其中 entries[i] = [shopi, moviei, pricei] 表示商店 shopi 有一份电影 moviei 的拷贝,租借价格为 pricei 。每个商店有 至多一份 编号为 moviei 的电影拷贝。

\n\n

系统需要支持以下操作:

\n\n\n\n

请你实现 MovieRentingSystem 类:

\n\n\n\n

注意:测试数据保证 rent 操作中指定商店拥有 未借出 的指定电影,且 drop 操作指定的商店 之前已借出 指定电影。

\n\n

 

\n\n

示例 1:

\n\n
\n输入:\n[\"MovieRentingSystem\", \"search\", \"rent\", \"rent\", \"report\", \"drop\", \"search\"]\n[[3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]], [1], [0, 1], [1, 2], [], [1, 2], [2]]\n输出:\n[null, [1, 0, 2], null, null, [[0, 1], [1, 2]], null, [0, 1]]\n\n解释:\nMovieRentingSystem movieRentingSystem = new MovieRentingSystem(3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]);\nmovieRentingSystem.search(1);  // 返回 [1, 0, 2] ,商店 1,0 和 2 有未借出的 ID 为 1 的电影。商店 1 最便宜,商店 0 和 2 价格相同,所以按商店编号排序。\nmovieRentingSystem.rent(0, 1); // 从商店 0 借出电影 1 。现在商店 0 未借出电影编号为 [2,3] 。\nmovieRentingSystem.rent(1, 2); // 从商店 1 借出电影 2 。现在商店 1 未借出的电影编号为 [1] 。\nmovieRentingSystem.report();   // 返回 [[0, 1], [1, 2]] 。商店 0 借出的电影 1 最便宜,然后是商店 1 借出的电影 2 。\nmovieRentingSystem.drop(1, 2); // 在商店 1 返还电影 2 。现在商店 1 未借出的电影编号为 [1,2] 。\nmovieRentingSystem.search(2);  // 返回 [0, 1] 。商店 0 和 1 有未借出的 ID 为 2 的电影。商店 0 最便宜,然后是商店 1 。\n
\n\n

 

\n\n

提示:

\n\n\n", "isPaidOnly": false, "difficulty": "Hard", "likes": 28, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", "topicTags": [ { "name": "Design", "slug": "design", "translatedName": "设计", "__typename": "TopicTagNode" }, { "name": "Array", "slug": "array", "translatedName": "数组", "__typename": "TopicTagNode" }, { "name": "Hash Table", "slug": "hash-table", "translatedName": "哈希表", "__typename": "TopicTagNode" }, { "name": "Ordered Set", "slug": "ordered-set", "translatedName": "有序集合", "__typename": "TopicTagNode" }, { "name": "Heap (Priority Queue)", "slug": "heap-priority-queue", "translatedName": "堆(优先队列)", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "C++", "langSlug": "cpp", "code": "class MovieRentingSystem {\npublic:\n MovieRentingSystem(int n, vector>& entries) {\n \n }\n \n vector search(int movie) {\n \n }\n \n void rent(int shop, int movie) {\n \n }\n \n void drop(int shop, int movie) {\n \n }\n \n vector> report() {\n \n }\n};\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * MovieRentingSystem* obj = new MovieRentingSystem(n, entries);\n * vector param_1 = obj->search(movie);\n * obj->rent(shop,movie);\n * obj->drop(shop,movie);\n * vector> param_4 = obj->report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "Java", "langSlug": "java", "code": "class MovieRentingSystem {\n\n public MovieRentingSystem(int n, int[][] entries) {\n\n }\n \n public List search(int movie) {\n\n }\n \n public void rent(int shop, int movie) {\n\n }\n \n public void drop(int shop, int movie) {\n\n }\n \n public List> report() {\n\n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * MovieRentingSystem obj = new MovieRentingSystem(n, entries);\n * List param_1 = obj.search(movie);\n * obj.rent(shop,movie);\n * obj.drop(shop,movie);\n * List> param_4 = obj.report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "Python", "langSlug": "python", "code": "class MovieRentingSystem(object):\n\n def __init__(self, n, entries):\n \"\"\"\n :type n: int\n :type entries: List[List[int]]\n \"\"\"\n\n\n def search(self, movie):\n \"\"\"\n :type movie: int\n :rtype: List[int]\n \"\"\"\n\n\n def rent(self, shop, movie):\n \"\"\"\n :type shop: int\n :type movie: int\n :rtype: None\n \"\"\"\n\n\n def drop(self, shop, movie):\n \"\"\"\n :type shop: int\n :type movie: int\n :rtype: None\n \"\"\"\n\n\n def report(self):\n \"\"\"\n :rtype: List[List[int]]\n \"\"\"\n\n\n\n# Your MovieRentingSystem object will be instantiated and called as such:\n# obj = MovieRentingSystem(n, entries)\n# param_1 = obj.search(movie)\n# obj.rent(shop,movie)\n# obj.drop(shop,movie)\n# param_4 = obj.report()", "__typename": "CodeSnippetNode" }, { "lang": "Python3", "langSlug": "python3", "code": "class MovieRentingSystem:\n\n def __init__(self, n: int, entries: List[List[int]]):\n\n\n def search(self, movie: int) -> List[int]:\n\n\n def rent(self, shop: int, movie: int) -> None:\n\n\n def drop(self, shop: int, movie: int) -> None:\n\n\n def report(self) -> List[List[int]]:\n\n\n\n# Your MovieRentingSystem object will be instantiated and called as such:\n# obj = MovieRentingSystem(n, entries)\n# param_1 = obj.search(movie)\n# obj.rent(shop,movie)\n# obj.drop(shop,movie)\n# param_4 = obj.report()", "__typename": "CodeSnippetNode" }, { "lang": "C", "langSlug": "c", "code": "typedef struct {\n \n} MovieRentingSystem;\n\n\nMovieRentingSystem* movieRentingSystemCreate(int n, int** entries, int entriesSize, int* entriesColSize) {\n \n}\n\nint* movieRentingSystemSearch(MovieRentingSystem* obj, int movie, int* retSize) {\n \n}\n\nvoid movieRentingSystemRent(MovieRentingSystem* obj, int shop, int movie) {\n \n}\n\nvoid movieRentingSystemDrop(MovieRentingSystem* obj, int shop, int movie) {\n \n}\n\nint** movieRentingSystemReport(MovieRentingSystem* obj, int* retSize, int** retColSize) {\n \n}\n\nvoid movieRentingSystemFree(MovieRentingSystem* obj) {\n \n}\n\n/**\n * Your MovieRentingSystem struct will be instantiated and called as such:\n * MovieRentingSystem* obj = movieRentingSystemCreate(n, entries, entriesSize, entriesColSize);\n * int* param_1 = movieRentingSystemSearch(obj, movie, retSize);\n \n * movieRentingSystemRent(obj, shop, movie);\n \n * movieRentingSystemDrop(obj, shop, movie);\n \n * int** param_4 = movieRentingSystemReport(obj, retSize, retColSize);\n \n * movieRentingSystemFree(obj);\n*/", "__typename": "CodeSnippetNode" }, { "lang": "C#", "langSlug": "csharp", "code": "public class MovieRentingSystem {\n\n public MovieRentingSystem(int n, int[][] entries) {\n \n }\n \n public IList Search(int movie) {\n \n }\n \n public void Rent(int shop, int movie) {\n \n }\n \n public void Drop(int shop, int movie) {\n \n }\n \n public IList> Report() {\n \n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * MovieRentingSystem obj = new MovieRentingSystem(n, entries);\n * IList param_1 = obj.Search(movie);\n * obj.Rent(shop,movie);\n * obj.Drop(shop,movie);\n * IList> param_4 = obj.Report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "JavaScript", "langSlug": "javascript", "code": "/**\n * @param {number} n\n * @param {number[][]} entries\n */\nvar MovieRentingSystem = function(n, entries) {\n\n};\n\n/** \n * @param {number} movie\n * @return {number[]}\n */\nMovieRentingSystem.prototype.search = function(movie) {\n\n};\n\n/** \n * @param {number} shop \n * @param {number} movie\n * @return {void}\n */\nMovieRentingSystem.prototype.rent = function(shop, movie) {\n\n};\n\n/** \n * @param {number} shop \n * @param {number} movie\n * @return {void}\n */\nMovieRentingSystem.prototype.drop = function(shop, movie) {\n\n};\n\n/**\n * @return {number[][]}\n */\nMovieRentingSystem.prototype.report = function() {\n\n};\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * var obj = new MovieRentingSystem(n, entries)\n * var param_1 = obj.search(movie)\n * obj.rent(shop,movie)\n * obj.drop(shop,movie)\n * var param_4 = obj.report()\n */", "__typename": "CodeSnippetNode" }, { "lang": "Ruby", "langSlug": "ruby", "code": "class MovieRentingSystem\n\n=begin\n :type n: Integer\n :type entries: Integer[][]\n=end\n def initialize(n, entries)\n\n end\n\n\n=begin\n :type movie: Integer\n :rtype: Integer[]\n=end\n def search(movie)\n\n end\n\n\n=begin\n :type shop: Integer\n :type movie: Integer\n :rtype: Void\n=end\n def rent(shop, movie)\n\n end\n\n\n=begin\n :type shop: Integer\n :type movie: Integer\n :rtype: Void\n=end\n def drop(shop, movie)\n\n end\n\n\n=begin\n :rtype: Integer[][]\n=end\n def report()\n\n end\n\n\nend\n\n# Your MovieRentingSystem object will be instantiated and called as such:\n# obj = MovieRentingSystem.new(n, entries)\n# param_1 = obj.search(movie)\n# obj.rent(shop, movie)\n# obj.drop(shop, movie)\n# param_4 = obj.report()", "__typename": "CodeSnippetNode" }, { "lang": "Swift", "langSlug": "swift", "code": "class MovieRentingSystem {\n\n init(_ n: Int, _ entries: [[Int]]) {\n \n }\n \n func search(_ movie: Int) -> [Int] {\n \n }\n \n func rent(_ shop: Int, _ movie: Int) {\n \n }\n \n func drop(_ shop: Int, _ movie: Int) {\n \n }\n \n func report() -> [[Int]] {\n \n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * let obj = MovieRentingSystem(n, entries)\n * let ret_1: [Int] = obj.search(movie)\n * obj.rent(shop, movie)\n * obj.drop(shop, movie)\n * let ret_4: [[Int]] = obj.report()\n */", "__typename": "CodeSnippetNode" }, { "lang": "Go", "langSlug": "golang", "code": "type MovieRentingSystem struct {\n\n}\n\n\nfunc Constructor(n int, entries [][]int) MovieRentingSystem {\n\n}\n\n\nfunc (this *MovieRentingSystem) Search(movie int) []int {\n\n}\n\n\nfunc (this *MovieRentingSystem) Rent(shop int, movie int) {\n\n}\n\n\nfunc (this *MovieRentingSystem) Drop(shop int, movie int) {\n\n}\n\n\nfunc (this *MovieRentingSystem) Report() [][]int {\n\n}\n\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * obj := Constructor(n, entries);\n * param_1 := obj.Search(movie);\n * obj.Rent(shop,movie);\n * obj.Drop(shop,movie);\n * param_4 := obj.Report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "Scala", "langSlug": "scala", "code": "class MovieRentingSystem(_n: Int, _entries: Array[Array[Int]]) {\n\n def search(movie: Int): List[Int] = {\n\n }\n\n def rent(shop: Int, movie: Int) {\n\n }\n\n def drop(shop: Int, movie: Int) {\n\n }\n\n def report(): List[List[Int]] = {\n\n }\n\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * var obj = new MovieRentingSystem(n, entries)\n * var param_1 = obj.search(movie)\n * obj.rent(shop,movie)\n * obj.drop(shop,movie)\n * var param_4 = obj.report()\n */", "__typename": "CodeSnippetNode" }, { "lang": "Kotlin", "langSlug": "kotlin", "code": "class MovieRentingSystem(n: Int, entries: Array) {\n\n fun search(movie: Int): List {\n\n }\n\n fun rent(shop: Int, movie: Int) {\n\n }\n\n fun drop(shop: Int, movie: Int) {\n\n }\n\n fun report(): List> {\n\n }\n\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * var obj = MovieRentingSystem(n, entries)\n * var param_1 = obj.search(movie)\n * obj.rent(shop,movie)\n * obj.drop(shop,movie)\n * var param_4 = obj.report()\n */", "__typename": "CodeSnippetNode" }, { "lang": "Rust", "langSlug": "rust", "code": "struct MovieRentingSystem {\n\n}\n\n\n/**\n * `&self` means the method takes an immutable reference.\n * If you need a mutable reference, change it to `&mut self` instead.\n */\nimpl MovieRentingSystem {\n\n fn new(n: i32, entries: Vec>) -> Self {\n\n }\n \n fn search(&self, movie: i32) -> Vec {\n\n }\n \n fn rent(&self, shop: i32, movie: i32) {\n\n }\n \n fn drop(&self, shop: i32, movie: i32) {\n\n }\n \n fn report(&self) -> Vec> {\n\n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * let obj = MovieRentingSystem::new(n, entries);\n * let ret_1: Vec = obj.search(movie);\n * obj.rent(shop, movie);\n * obj.drop(shop, movie);\n * let ret_4: Vec> = obj.report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "PHP", "langSlug": "php", "code": "class MovieRentingSystem {\n /**\n * @param Integer $n\n * @param Integer[][] $entries\n */\n function __construct($n, $entries) {\n\n }\n\n /**\n * @param Integer $movie\n * @return Integer[]\n */\n function search($movie) {\n\n }\n\n /**\n * @param Integer $shop\n * @param Integer $movie\n * @return NULL\n */\n function rent($shop, $movie) {\n\n }\n\n /**\n * @param Integer $shop\n * @param Integer $movie\n * @return NULL\n */\n function drop($shop, $movie) {\n\n }\n\n /**\n * @return Integer[][]\n */\n function report() {\n\n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * $obj = MovieRentingSystem($n, $entries);\n * $ret_1 = $obj->search($movie);\n * $obj->rent($shop, $movie);\n * $obj->drop($shop, $movie);\n * $ret_4 = $obj->report();\n */", "__typename": "CodeSnippetNode" }, { "lang": "TypeScript", "langSlug": "typescript", "code": "class MovieRentingSystem {\n constructor(n: number, entries: number[][]) {\n\n }\n\n search(movie: number): number[] {\n\n }\n\n rent(shop: number, movie: number): void {\n\n }\n\n drop(shop: number, movie: number): void {\n\n }\n\n report(): number[][] {\n\n }\n}\n\n/**\n * Your MovieRentingSystem object will be instantiated and called as such:\n * var obj = new MovieRentingSystem(n, entries)\n * var param_1 = obj.search(movie)\n * obj.rent(shop,movie)\n * obj.drop(shop,movie)\n * var param_4 = obj.report()\n */", "__typename": "CodeSnippetNode" }, { "lang": "Racket", "langSlug": "racket", "code": "(define movie-renting-system%\n (class object%\n (super-new)\n\n ; n : exact-integer?\n\n ; entries : (listof (listof exact-integer?))\n (init-field\n n\n entries)\n \n ; search : exact-integer? -> (listof exact-integer?)\n (define/public (search movie)\n\n )\n ; rent : exact-integer? exact-integer? -> void?\n (define/public (rent shop movie)\n\n )\n ; drop : exact-integer? exact-integer? -> void?\n (define/public (drop shop movie)\n\n )\n ; report : -> (listof (listof exact-integer?))\n (define/public (report)\n\n )))\n\n;; Your movie-renting-system% object will be instantiated and called as such:\n;; (define obj (new movie-renting-system% [n n] [entries entries]))\n;; (define param_1 (send obj search movie))\n;; (send obj rent shop movie)\n;; (send obj drop shop movie)\n;; (define param_4 (send obj report))", "__typename": "CodeSnippetNode" }, { "lang": "Erlang", "langSlug": "erlang", "code": "-spec movie_renting_system_init_(N :: integer(), Entries :: [[integer()]]) -> any().\nmovie_renting_system_init_(N, Entries) ->\n .\n\n-spec movie_renting_system_search(Movie :: integer()) -> [integer()].\nmovie_renting_system_search(Movie) ->\n .\n\n-spec movie_renting_system_rent(Shop :: integer(), Movie :: integer()) -> any().\nmovie_renting_system_rent(Shop, Movie) ->\n .\n\n-spec movie_renting_system_drop(Shop :: integer(), Movie :: integer()) -> any().\nmovie_renting_system_drop(Shop, Movie) ->\n .\n\n-spec movie_renting_system_report() -> [[integer()]].\nmovie_renting_system_report() ->\n .\n\n\n%% Your functions will be called as such:\n%% movie_renting_system_init_(N, Entries),\n%% Param_1 = movie_renting_system_search(Movie),\n%% movie_renting_system_rent(Shop, Movie),\n%% movie_renting_system_drop(Shop, Movie),\n%% Param_4 = movie_renting_system_report(),\n\n%% movie_renting_system_init_ will be called before every test case, in which you can do some necessary initializations.", "__typename": "CodeSnippetNode" }, { "lang": "Elixir", "langSlug": "elixir", "code": "defmodule MovieRentingSystem do\n @spec init_(n :: integer, entries :: [[integer]]) :: any\n def init_(n, entries) do\n\n end\n\n @spec search(movie :: integer) :: [integer]\n def search(movie) do\n\n end\n\n @spec rent(shop :: integer, movie :: integer) :: any\n def rent(shop, movie) do\n\n end\n\n @spec drop(shop :: integer, movie :: integer) :: any\n def drop(shop, movie) do\n\n end\n\n @spec report() :: [[integer]]\n def report() do\n\n end\nend\n\n# Your functions will be called as such:\n# MovieRentingSystem.init_(n, entries)\n# param_1 = MovieRentingSystem.search(movie)\n# MovieRentingSystem.rent(shop, movie)\n# MovieRentingSystem.drop(shop, movie)\n# param_4 = MovieRentingSystem.report()\n\n# MovieRentingSystem.init_ will be called before every test case, in which you can do some necessary initializations.", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"2.6K\", \"totalSubmission\": \"10.9K\", \"totalAcceptedRaw\": 2573, \"totalSubmissionRaw\": 10933, \"acRate\": \"23.5%\"}", "hints": [ "You need to maintain a sorted list for each movie and a sorted list for rented movies", "When renting a movie remove it from its movies sorted list and added it to the rented list and vice versa in the case of dropping a movie" ], "solution": null, "status": null, "sampleTestCase": "[\"MovieRentingSystem\",\"search\",\"rent\",\"rent\",\"report\",\"drop\",\"search\"]\n[[3,[[0,1,5],[0,2,6],[0,3,7],[1,1,4],[1,2,7],[2,1,5]]],[1],[0,1],[1,2],[],[1,2],[2]]", "metaData": "{\n \"classname\": \"MovieRentingSystem\",\n \"constructor\": {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"n\"\n },\n {\n \"name\": \"entries\",\n \"type\": \"integer[][]\"\n }\n ]\n },\n \"methods\": [\n {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"movie\"\n }\n ],\n \"name\": \"search\",\n \"return\": {\n \"type\": \"list\"\n }\n },\n {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"shop\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"movie\"\n }\n ],\n \"name\": \"rent\",\n \"return\": {\n \"type\": \"void\"\n }\n },\n {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"shop\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"movie\"\n }\n ],\n \"name\": \"drop\",\n \"return\": {\n \"type\": \"void\"\n }\n },\n {\n \"params\": [],\n \"name\": \"report\",\n \"return\": {\n \"type\": \"list>\"\n }\n }\n ],\n \"return\": {\n \"type\": \"boolean\"\n },\n \"systemdesign\": true,\n \"manual\": false\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": true, "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-after-free<\\/code>\\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u4f7f\\u7528\\u65b9\\u4fbf\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8\\u5bfc\\u5165\\u3002<\\/p>\"],\"java\":[\"Java\",\"

\\u7248\\u672c\\uff1aOpenJDK 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u88ab\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n

\\u5305\\u542b Pair \\u7c7b: https:\\/\\/docs.oracle.com\\/javase\\/8\\/javafx\\/api\\/javafx\\/util\\/Pair.html <\\/p>\"],\"python\":[\"Python\",\"

\\u7248\\u672c\\uff1a Python 2.7.12<\\/code><\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982\\uff1aarray<\\/a>, bisect<\\/a>, collections<\\/a>\\u3002\\u5982\\u679c\\u60a8\\u9700\\u8981\\u4f7f\\u7528\\u5176\\u4ed6\\u5e93\\u51fd\\u6570\\uff0c\\u8bf7\\u81ea\\u884c\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n

\\u6ce8\\u610f Python 2.7 \\u5c06\\u57282020\\u5e74\\u540e\\u4e0d\\u518d\\u7ef4\\u62a4<\\/a>\\u3002 \\u5982\\u60f3\\u4f7f\\u7528\\u6700\\u65b0\\u7248\\u7684Python\\uff0c\\u8bf7\\u9009\\u62e9Python 3\\u3002<\\/p>\"],\"c\":[\"C\",\"

\\u7248\\u672c\\uff1aGCC 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-after-free<\\/code>\\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u4f7f\\u7528\\u65b9\\u4fbf\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n

\\u5982\\u60f3\\u4f7f\\u7528\\u54c8\\u5e0c\\u8868\\u8fd0\\u7b97, \\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 uthash<\\/a>\\u3002 \\\"uthash.h\\\"\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5bfc\\u5165\\u3002\\u8bf7\\u770b\\u5982\\u4e0b\\u793a\\u4f8b:<\\/p>\\r\\n\\r\\n

1. \\u5f80\\u54c8\\u5e0c\\u8868\\u4e2d\\u6dfb\\u52a0\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            \\/* we'll use this field as the key *\\/\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; \\/* makes this structure hashable *\\/\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\\r\\n\\r\\n

2. \\u5728\\u54c8\\u5e0c\\u8868\\u4e2d\\u67e5\\u627e\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\\r\\n\\r\\n

3. \\u4ece\\u54c8\\u5e0c\\u8868\\u4e2d\\u5220\\u9664\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\"],\"csharp\":[\"C#\",\"

C# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/code><\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a --harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f \\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n

lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n

\\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 datastructures-js\\/priority-queue<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/code>\\u6267\\u884c<\\/p>\\r\\n\\r\\n

\\u4e00\\u4e9b\\u5e38\\u7528\\u7684\\u6570\\u636e\\u7ed3\\u6784\\u5df2\\u5728 Algorithms \\u6a21\\u5757\\u4e2d\\u63d0\\u4f9b\\uff1ahttps:\\/\\/www.rubydoc.info\\/github\\/kanwei\\/algorithms\\/Algorithms<\\/p>\"],\"swift\":[\"Swift\",\"

\\u7248\\u672c\\uff1aSwift 5.5.2<\\/code><\\/p>\\r\\n\\r\\n

\\u6211\\u4eec\\u901a\\u5e38\\u4fdd\\u8bc1\\u66f4\\u65b0\\u5230 Apple\\u653e\\u51fa\\u7684\\u6700\\u65b0\\u7248Swift<\\/a>\\u3002\\u5982\\u679c\\u60a8\\u53d1\\u73b0Swift\\u4e0d\\u662f\\u6700\\u65b0\\u7248\\u7684\\uff0c\\u8bf7\\u8054\\u7cfb\\u6211\\u4eec\\uff01\\u6211\\u4eec\\u5c06\\u5c3d\\u5feb\\u66f4\\u65b0\\u3002<\\/p>\"],\"golang\":[\"Go\",\"

\\u7248\\u672c\\uff1aGo 1.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/code><\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982array<\\/a>, bisect<\\/a>, collections<\\/a>\\u3002 \\u5982\\u679c\\u60a8\\u9700\\u8981\\u4f7f\\u7528\\u5176\\u4ed6\\u5e93\\u51fd\\u6570\\uff0c\\u8bf7\\u81ea\\u884c\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n

\\u5982\\u9700\\u4f7f\\u7528 Map\\/TreeMap \\u6570\\u636e\\u7ed3\\u6784\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 sortedcontainers<\\/a> \\u5e93\\u3002<\\/p>\"],\"scala\":[\"Scala\",\"

\\u7248\\u672c\\uff1aScala 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

\\u7248\\u672c\\uff1aKotlin 1.3.10<\\/code><\\/p>\"],\"rust\":[\"Rust\",\"

\\u7248\\u672c\\uff1arust 1.58.1<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 crates.io \\u7684 rand<\\/a><\\/p>\"],\"php\":[\"PHP\",\"

PHP 8.1<\\/code>.<\\/p>\\r\\n\\r\\n

With bcmath module.<\\/p>\"],\"typescript\":[\"TypeScript\",\"

TypeScript 4.5.4<\\/p>\\r\\n\\r\\n

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/p>\\r\\n\\r\\n

\\u4f7f\\u7528 #lang racket<\\/p>\\r\\n\\r\\n

\\u5df2\\u9884\\u5148 (require data\\/gvector data\\/queue data\\/order data\\/heap). \\u82e5\\u9700\\u4f7f\\u7528\\u5176\\u5b83\\u6570\\u636e\\u7ed3\\u6784\\uff0c\\u53ef\\u81ea\\u884c require\\u3002<\\/p>\"],\"erlang\":[\"Erlang\",\"Erlang\\/OTP 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", "book": null, "isSubscribed": false, "isDailyQuestion": false, "dailyRecordStatus": null, "editorType": "CKEDITOR", "ugcQuestionId": null, "style": "LEETCODE", "exampleTestcases": "[\"MovieRentingSystem\",\"search\",\"rent\",\"rent\",\"report\",\"drop\",\"search\"]\n[[3,[[0,1,5],[0,2,6],[0,3,7],[1,1,4],[1,2,7],[2,1,5]]],[1],[0,1],[1,2],[],[1,2],[2]]", "__typename": "QuestionNode" } } }