2022-03-27 18:27:43 +08:00
{
"data" : {
"question" : {
"questionId" : "2023" ,
"questionFrontendId" : "1912" ,
"boundTopicId" : null ,
"title" : "Design Movie Rental System" ,
"titleSlug" : "design-movie-rental-system" ,
"content" : " < p > Y o u h a v e a m o v i e r e n t i n g c o m p a n y c o n s i s t i n g o f < c o d e > n < / c o d e > s h o p s . Y o u w a n t t o i m p l e m e n t a r e n t i n g s y s t e m t h a t s u p p o r t s s e a r c h i n g f o r , b o o k i n g , a n d r e t u r n i n g m o v i e s . T h e s y s t e m s h o u l d a l s o s u p p o r t g e n e r a t i n g a r e p o r t o f t h e c u r r e n t l y r e n t e d m o v i e s . < / p > \ r \ n \ r \ n < p > E a c h m o v i e i s g i v e n a s a 2 D i n t e g e r a r r a y < c o d e > e n t r i e s < / c o d e > w h e r e < c o d e > e n t r i e s [ i ] = [ s h o p < s u b > i < / s u b > , m o v i e < s u b > i < / s u b > , p r i c e < s u b > i < / s u b > ] < / c o d e > i n d i c a t e s t h a t t h e r e i s a c o p y o f m o v i e < c o d e > m o v i e < s u b > i < / s u b > < / c o d e > a t s h o p < c o d e > s h o p < s u b > i < / s u b > < / c o d e > w i t h a r e n t a l p r i c e o f < c o d e > p r i c e < s u b > i < / s u b > < / c o d e > . E a c h s h o p c a r r i e s < s t r o n g > a t m o s t o n e < / s t r o n g > c o p y o f a m o v i e < c o d e > m o v i e < s u b > i < / s u b > < / c o d e > . < / p > \ r \ n \ r \ n < p > T h e s y s t e m s h o u l d s u p p o r t t h e f o l l o w i n g f u n c t i o n s : < / p > \ r \ n \ r \ n < u l > \ r \ n \ t < l i > < s t r o n g > S e a r c h < / s t r o n g > : F i n d s t h e < s t r o n g > c h e a p e s t 5 s h o p s < / s t r o n g > t h a t h a v e a n < s t r o n g > u n r e n t e d c o p y < / s t r o n g > o f a g i v e n m o v i e . T h e s h o p s s h o u l d b e s o r t e d b y < s t r o n g > p r i c e < / s t r o n g > i n a s c e n d i n g o r d e r , a n d i n c a s e o f a t i e , t h e o n e w i t h t h e < s t r o n g > s m a l l e r < / s t r o n g > < c o d e > s h o p < s u b > i < / s u b > < / c o d e > s h o u l d a p p e a r f i r s t . I f t h e r e a r e l e s s t h a n 5 m a t c h i n g s h o p s , t h e n a l l o f t h e m s h o u l d b e r e t u r n e d . I f n o s h o p h a s a n u n r e n t e d c o p y , t h e n a n e m p t y l i s t s h o u l d b e r e t u r n e d . < / l i > \ r \ n \ t < l i > < s t r o n g > R e n t < / s t r o n g > : R e n t s a n < s t r o n g > u n r e n t e d c o p y < / s t r o n g > o f a g i v e n m o v i e f r o m a g i v e n s h o p . < / l i > \ r \ n \ t < l i > < s t r o n g > D r o p < / s t r o n g > : D r o p s o f f a < s t r o n g > p r e v i o u s l y r e n t e d c o p y < / s t r o n g > o f a g i v e n m o v i e a t a g i v e n s h o p . < / l i > \ r \ n \ t < l i > < s t r o n g > R e p o r t < / s t r o n g > : R e t u r n s t h e < s t r o n g > c h e a p e s t 5 r e n t e d m o v i e s < / s t r o n g > ( p o s s i b l y o f t h e s a m e m o v i e I D ) a s a 2 D l i s t < c o d e > r e s < / c o d e > w h e r e < c o d e > r e s [ j ] = [ s h o p < s u b > j < / s u b > , m o v i e < s u b > j < / s u b > ] < / c o d e > d e s c r i b e s t h a t t h e < c o d e > j < s u p > t h < / s u p > < / c o d e > c h e a p e s t r e n t e d m o v i e < c o d e > m o v i e < s u b > j < / s u b > < / c o d e > w a s r e n t e d f r o m t h e s h o p < c o d e > s h o p < s u b > j < / s u b > < / c o d e > . T h e m o v i e s i n < c o d e > r e s < / c o d e > s h o u l d b e s o r t e d b y < s t r o n g > p r i c e < / s t r o n g > i n a s c e n d i n g o r d e r , a n d i n c a s e o f a t i e , t h e o n e w i t h t h e < s t r o n g > s m a l l e r < / s t r o n g > < c o d e > s h o p < s u b > j < / s u b > < / c o d e > s h o u l d a p p e a r f i r s t , a n d i f t h e r e i s s t i l l t i e , t h e o n e w i t h t h e < s t r o n g > s m a l l e r < / s t r o n g > < c o d e > m o v i e < s u b > j < / s u b > < / c o d e > s h o u l d a p p e a r f i r s t . I f t h e r e a r e f e w e r t h a n 5 r e n t e d m o v i e s , t h e n a l l o f t h e m s h o u l d b e r e t u r n e d . I f n o m o v i e s a r e c u r r e n t l y b e i n g r e n t e d , t h e n a n e m p t y l i s t s h o u l d b e r e t u r n e d . < / l i > \ r \ n < / u l > \ r \ n \ r \ n < p > I m p l e m e n t t h e < c o d e > M o v i e R e n t i n g S y s t e m < / c o d e > c l a s s : < / p > \ r \ n \ r \ n < u l > \ r \ n \ t < l i > < c o d e > M o v i e R e n t i n g S y s t e m ( i n t n , i n t [ ] [ ] e n t r i e s ) < / c o d e > I n i t i a l i z e s t h e < c o d e > M o v i e R e n t i n g S y s t e m < / c o d e > o b j e c t w i t h < c o d e > n < / c o d e > s h o p s a n d t h e m o v i e s i n < c o d e > e n t r i e s < / c o d e > . < / l i > \ r \ n \ t < l i > < c o d e > L i s t & l t ; I n t e g e r & g t ; s e a r c h ( i n t m o v i e ) < / c o d e > R e t u r n s a l i s t o f s h o p s t h a t h a v e a n < s t r o n g > u n r e n t e d c o p y < / s t r o n g > o f t h e g i v e n < c o d e > m o v i e < / c o d e > a s d e s c r i b e d a b o v e . < / l i > \ r \ n \ t < l i > < c o d e > v o i d r e n t ( i n t s h o p , i n t m o v i e ) < / c o d e > R e n t s t h e g i v e n < c o d e > m o v i e < / c o d e > f r o m t h e g i v e n < c o d e > s h o p < / c o d e > . < / l i > \ r \ n \ t < l i > < c o d e > v o i d d r o p ( i n t s h o p , i n t m o v i e ) < / c o d e > D r o p s o f f a p r e v i o u s l y r e n t e d < c o d e > m o v i e < / c o d e > a t t h e g i v e n < c o d e > s h o p < / c o d e > . < / l i > \ r \ n \ t < l i > < c o d e > L i s t & l t ; L i s t & l t ; I n t e g e r & g t ; & g t ; r e p o r t ( ) < / c o d e > R e t u r n s a l i s t o f c h e a p e s t < s t r o n g > r e n t e d < / s t r o n g > m o v i e s a s d e s c r i b e d a b o v e . < / l i > \ r \ n < / u l > \ r \ n \ r \ n < p > < s t r o n g > N o t e : < / s t r o n g > T h e t e s t c a s e s w i l l b e g e n e r a t e d s u c h t h a t < c o d e > r e n t < / c o d e > w i l l o n l y b e c a l l e d i f t h e s h o p h a s a n < s t r o n g > u n r e n t e d < / s t r o n g > c o p y o f t h e m o v i e , a n d < c o d e > d r o p < / c o d e > w i l l o n l y b e c a l l e d i f t h e s h o p h a d < s t r o n g > p r e v i o u s l y r e n t e d < / s t r o n g > o u t t h e m o v i e . < / p > \ r \ n \ r \ n < p > & n b s p ; < / p > \ r \ n < p > < s t r o n g > E x a m p l e 1 : < / s t r o n g > < / p > \ r \ n \ r \ n < p r e > \ r \ n < s t r o n g > I n p u t < / s t r o n g > \ r \ n [ & q u o t ; M o v i e R e n t i n g S y s t e m & q u o t ; , & q u o t ; s e a r c h & q u o t ; , & q u o t ; r e n t & q u o t ; , & q u o t ; r e n t & q u o t ; , & q u o t ; r e p o r t & q u o t ; , & q u o t ; d r o p & q u o t ; , & q u o t ; s e a r c h & q u o t ; ] \ 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 \ n < s t r o n g > O u t p u t < / s t r o n g > \ r \ n [ null , [ 1 , 0 , 2 ] , null , null , [ [ 0 , 1 ] , [ 1 , 2 ] ] , null , [ 0 , 1 ] ] \ r \ n \ r \ n < s t r o n g > E x p l a n a t i o n < / s t r o n g > \ r \ n M o v i e R e n t i n g S y s t e m m o v i e R e n t i n g S y s t e m = n e w M o v i e R e n t i n g S y
"translatedTitle" : null ,
"translatedContent" : null ,
"isPaidOnly" : false ,
"difficulty" : "Hard" ,
"likes" : 138 ,
"dislikes" : 27 ,
"isLiked" : null ,
"similarQuestions" : "[]" ,
"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]]" ,
"categoryTitle" : "Algorithms" ,
"contributors" : [ ] ,
"topicTags" : [
{
"name" : "Array" ,
"slug" : "array" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
} ,
{
"name" : "Hash Table" ,
"slug" : "hash-table" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
} ,
{
"name" : "Design" ,
"slug" : "design" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
} ,
{
"name" : "Heap (Priority Queue)" ,
"slug" : "heap-priority-queue" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
} ,
{
"name" : "Ordered Set" ,
"slug" : "ordered-set" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
}
] ,
"companyTagStats" : null ,
"codeSnippets" : [
{
"lang" : "C++" ,
"langSlug" : "cpp" ,
"code" : "class MovieRentingSystem {\r\npublic:\r\n MovieRentingSystem(int n, vector<vector<int>>& entries) {\r\n \r\n }\r\n \r\n vector<int> search(int movie) {\r\n \r\n }\r\n \r\n void rent(int shop, int movie) {\r\n \r\n }\r\n \r\n void drop(int shop, int movie) {\r\n \r\n }\r\n \r\n vector<vector<int>> report() {\r\n \r\n }\r\n};\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * MovieRentingSystem* obj = new MovieRentingSystem(n, entries);\r\n * vector<int> param_1 = obj->search(movie);\r\n * obj->rent(shop,movie);\r\n * obj->drop(shop,movie);\r\n * vector<vector<int>> param_4 = obj->report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Java" ,
"langSlug" : "java" ,
"code" : "class MovieRentingSystem {\r\n\r\n public MovieRentingSystem(int n, int[][] entries) {\r\n \r\n }\r\n \r\n public List<Integer> search(int movie) {\r\n \r\n }\r\n \r\n public void rent(int shop, int movie) {\r\n \r\n }\r\n \r\n public void drop(int shop, int movie) {\r\n \r\n }\r\n \r\n public List<List<Integer>> report() {\r\n \r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * MovieRentingSystem obj = new MovieRentingSystem(n, entries);\r\n * List<Integer> param_1 = obj.search(movie);\r\n * obj.rent(shop,movie);\r\n * obj.drop(shop,movie);\r\n * List<List<Integer>> param_4 = obj.report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Python" ,
"langSlug" : "python" ,
"code" : "class MovieRentingSystem(object):\r\n\r\n def __init__(self, n, entries):\r\n \"\"\"\r\n :type n: int\r\n :type entries: List[List[int]]\r\n \"\"\"\r\n \r\n\r\n def search(self, movie):\r\n \"\"\"\r\n :type movie: int\r\n :rtype: List[int]\r\n \"\"\"\r\n \r\n\r\n def rent(self, shop, movie):\r\n \"\"\"\r\n :type shop: int\r\n :type movie: int\r\n :rtype: None\r\n \"\"\"\r\n \r\n\r\n def drop(self, shop, movie):\r\n \"\"\"\r\n :type shop: int\r\n :type movie: int\r\n :rtype: None\r\n \"\"\"\r\n \r\n\r\n def report(self):\r\n \"\"\"\r\n :rtype: List[List[int]]\r\n \"\"\"\r\n \r\n\r\n\r\n# Your MovieRentingSystem object will be instantiated and called as such:\r\n# obj = MovieRentingSystem(n, entries)\r\n# param_1 = obj.search(movie)\r\n# obj.rent(shop,movie)\r\n# obj.drop(shop,movie)\r\n# param_4 = obj.report()" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Python3" ,
"langSlug" : "python3" ,
"code" : "class MovieRentingSystem:\r\n\r\n def __init__(self, n: int, entries: List[List[int]]):\r\n \r\n\r\n def search(self, movie: int) -> List[int]:\r\n \r\n\r\n def rent(self, shop: int, movie: int) -> None:\r\n \r\n\r\n def drop(self, shop: int, movie: int) -> None:\r\n \r\n\r\n def report(self) -> List[List[int]]:\r\n \r\n\r\n\r\n# Your MovieRentingSystem object will be instantiated and called as such:\r\n# obj = MovieRentingSystem(n, entries)\r\n# param_1 = obj.search(movie)\r\n# obj.rent(shop,movie)\r\n# obj.drop(shop,movie)\r\n# param_4 = obj.report()" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "C" ,
"langSlug" : "c" ,
"code" : "typedef struct {\r\n \r\n} MovieRentingSystem;\r\n\r\n\r\nMovieRentingSystem* movieRentingSystemCreate(int n, int** entries, int entriesSize, int* entriesColSize) {\r\n \r\n}\r\n\r\nint* movieRentingSystemSearch(MovieRentingSystem* obj, int movie, int* retSize) {\r\n \r\n}\r\n\r\nvoid movieRentingSystemRent(MovieRentingSystem* obj, int shop, int movie) {\r\n \r\n}\r\n\r\nvoid movieRentingSystemDrop(MovieRentingSystem* obj, int shop, int movie) {\r\n \r\n}\r\n\r\nint** movieRentingSystemReport(MovieRentingSystem* obj, int* retSize, int** retColSize) {\r\n \r\n}\r\n\r\nvoid movieRentingSystemFree(MovieRentingSystem* obj) {\r\n \r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem struct will be instantiated and called as such:\r\n * MovieRentingSystem* obj = movieRentingSystemCreate(n, entries, entriesSize, entriesColSize);\r\n * int* param_1 = movieRentingSystemSearch(obj, movie, retSize);\r\n \r\n * movieRentingSystemRent(obj, shop, movie);\r\n \r\n * movieRentingSystemDrop(obj, shop, movie);\r\n \r\n * int** param_4 = movieRentingSystemReport(obj, retSize, retColSize);\r\n \r\n * movieRentingSystemFree(obj);\r\n*/" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "C#" ,
"langSlug" : "csharp" ,
"code" : "public class MovieRentingSystem {\r\n\r\n public MovieRentingSystem(int n, int[][] entries) {\r\n \r\n }\r\n \r\n public IList<int> Search(int movie) {\r\n \r\n }\r\n \r\n public void Rent(int shop, int movie) {\r\n \r\n }\r\n \r\n public void Drop(int shop, int movie) {\r\n \r\n }\r\n \r\n public IList<IList<int>> Report() {\r\n \r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * MovieRentingSystem obj = new MovieRentingSystem(n, entries);\r\n * IList<int> param_1 = obj.Search(movie);\r\n * obj.Rent(shop,movie);\r\n * obj.Drop(shop,movie);\r\n * IList<IList<int>> param_4 = obj.Report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "JavaScript" ,
"langSlug" : "javascript" ,
"code" : "/**\r\n * @param {number} n\r\n * @param {number[][]} entries\r\n */\r\nvar MovieRentingSystem = function(n, entries) {\r\n \r\n};\r\n\r\n/** \r\n * @param {number} movie\r\n * @return {number[]}\r\n */\r\nMovieRentingSystem.prototype.search = function(movie) {\r\n \r\n};\r\n\r\n/** \r\n * @param {number} shop \r\n * @param {number} movie\r\n * @return {void}\r\n */\r\nMovieRentingSystem.prototype.rent = function(shop, movie) {\r\n \r\n};\r\n\r\n/** \r\n * @param {number} shop \r\n * @param {number} movie\r\n * @return {void}\r\n */\r\nMovieRentingSystem.prototype.drop = function(shop, movie) {\r\n \r\n};\r\n\r\n/**\r\n * @return {number[][]}\r\n */\r\nMovieRentingSystem.prototype.report = function() {\r\n \r\n};\r\n\r\n/** \r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * var obj = new MovieRentingSystem(n, entries)\r\n * var param_1 = obj.search(movie)\r\n * obj.rent(shop,movie)\r\n * obj.drop(shop,movie)\r\n * var param_4 = obj.report()\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Ruby" ,
"langSlug" : "ruby" ,
"code" : "class MovieRentingSystem\r\n\r\n=begin\r\n :type n: Integer\r\n :type entries: Integer[][]\r\n=end\r\n def initialize(n, entries)\r\n \r\n end\r\n\r\n\r\n=begin\r\n :type movie: Integer\r\n :rtype: Integer[]\r\n=end\r\n def search(movie)\r\n \r\n end\r\n\r\n\r\n=begin\r\n :type shop: Integer\r\n :type movie: Integer\r\n :rtype: Void\r\n=end\r\n def rent(shop, movie)\r\n \r\n end\r\n\r\n\r\n=begin\r\n :type shop: Integer\r\n :type movie: Integer\r\n :rtype: Void\r\n=end\r\n def drop(shop, movie)\r\n \r\n end\r\n\r\n\r\n=begin\r\n :rtype: Integer[][]\r\n=end\r\n def report()\r\n \r\n end\r\n\r\n\r\nend\r\n\r\n# Your MovieRentingSystem object will be instantiated and called as such:\r\n# obj = MovieRentingSystem.new(n, entries)\r\n# param_1 = obj.search(movie)\r\n# obj.rent(shop, movie)\r\n# obj.drop(shop, movie)\r\n# param_4 = obj.report()" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Swift" ,
"langSlug" : "swift" ,
"code" : "class MovieRentingSystem {\r\n\r\n init(_ n: Int, _ entries: [[Int]]) {\r\n \r\n }\r\n \r\n func search(_ movie: Int) -> [Int] {\r\n \r\n }\r\n \r\n func rent(_ shop: Int, _ movie: Int) {\r\n \r\n }\r\n \r\n func drop(_ shop: Int, _ movie: Int) {\r\n \r\n }\r\n \r\n func report() -> [[Int]] {\r\n \r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * let obj = MovieRentingSystem(n, entries)\r\n * let ret_1: [Int] = obj.search(movie)\r\n * obj.rent(shop, movie)\r\n * obj.drop(shop, movie)\r\n * let ret_4: [[Int]] = obj.report()\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Go" ,
"langSlug" : "golang" ,
"code" : "type MovieRentingSystem struct {\r\n \r\n}\r\n\r\n\r\nfunc Constructor(n int, entries [][]int) MovieRentingSystem {\r\n \r\n}\r\n\r\n\r\nfunc (this *MovieRentingSystem) Search(movie int) []int {\r\n \r\n}\r\n\r\n\r\nfunc (this *MovieRentingSystem) Rent(shop int, movie int) {\r\n \r\n}\r\n\r\n\r\nfunc (this *MovieRentingSystem) Drop(shop int, movie int) {\r\n \r\n}\r\n\r\n\r\nfunc (this *MovieRentingSystem) Report() [][]int {\r\n \r\n}\r\n\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * obj := Constructor(n, entries);\r\n * param_1 := obj.Search(movie);\r\n * obj.Rent(shop,movie);\r\n * obj.Drop(shop,movie);\r\n * param_4 := obj.Report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Scala" ,
"langSlug" : "scala" ,
"code" : "class MovieRentingSystem(_n: Int, _entries: Array[Array[Int]]) {\r\n\r\n def search(movie: Int): List[Int] = {\r\n \r\n }\r\n\r\n def rent(shop: Int, movie: Int) {\r\n \r\n }\r\n\r\n def drop(shop: Int, movie: Int) {\r\n \r\n }\r\n\r\n def report(): List[List[Int]] = {\r\n \r\n }\r\n\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * var obj = new MovieRentingSystem(n, entries)\r\n * var param_1 = obj.search(movie)\r\n * obj.rent(shop,movie)\r\n * obj.drop(shop,movie)\r\n * var param_4 = obj.report()\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Kotlin" ,
"langSlug" : "kotlin" ,
"code" : "class MovieRentingSystem(n: Int, entries: Array<IntArray>) {\r\n\r\n fun search(movie: Int): List<Int> {\r\n \r\n }\r\n\r\n fun rent(shop: Int, movie: Int) {\r\n \r\n }\r\n\r\n fun drop(shop: Int, movie: Int) {\r\n \r\n }\r\n\r\n fun report(): List<List<Int>> {\r\n \r\n }\r\n\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * var obj = MovieRentingSystem(n, entries)\r\n * var param_1 = obj.search(movie)\r\n * obj.rent(shop,movie)\r\n * obj.drop(shop,movie)\r\n * var param_4 = obj.report()\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Rust" ,
"langSlug" : "rust" ,
"code" : "struct MovieRentingSystem {\r\n\r\n}\r\n\r\n\r\n/** \r\n * `&self` means the method takes an immutable reference.\r\n * If you need a mutable reference, change it to `&mut self` instead.\r\n */\r\nimpl MovieRentingSystem {\r\n\r\n fn new(n: i32, entries: Vec<Vec<i32>>) -> Self {\r\n \r\n }\r\n \r\n fn search(&self, movie: i32) -> Vec<i32> {\r\n \r\n }\r\n \r\n fn rent(&self, shop: i32, movie: i32) {\r\n \r\n }\r\n \r\n fn drop(&self, shop: i32, movie: i32) {\r\n \r\n }\r\n \r\n fn report(&self) -> Vec<Vec<i32>> {\r\n \r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * let obj = MovieRentingSystem::new(n, entries);\r\n * let ret_1: Vec<i32> = obj.search(movie);\r\n * obj.rent(shop, movie);\r\n * obj.drop(shop, movie);\r\n * let ret_4: Vec<Vec<i32>> = obj.report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "PHP" ,
"langSlug" : "php" ,
"code" : "class MovieRentingSystem {\r\n /**\r\n * @param Integer $n\r\n * @param Integer[][] $entries\r\n */\r\n function __construct($n, $entries) {\r\n \r\n }\r\n \r\n /**\r\n * @param Integer $movie\r\n * @return Integer[]\r\n */\r\n function search($movie) {\r\n \r\n }\r\n \r\n /**\r\n * @param Integer $shop\r\n * @param Integer $movie\r\n * @return NULL\r\n */\r\n function rent($shop, $movie) {\r\n \r\n }\r\n \r\n /**\r\n * @param Integer $shop\r\n * @param Integer $movie\r\n * @return NULL\r\n */\r\n function drop($shop, $movie) {\r\n \r\n }\r\n \r\n /**\r\n * @return Integer[][]\r\n */\r\n function report() {\r\n \r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * $obj = MovieRentingSystem($n, $entries);\r\n * $ret_1 = $obj->search($movie);\r\n * $obj->rent($shop, $movie);\r\n * $obj->drop($shop, $movie);\r\n * $ret_4 = $obj->report();\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "TypeScript" ,
"langSlug" : "typescript" ,
"code" : "class MovieRentingSystem {\r\n constructor(n: number, entries: number[][]) {\r\n\r\n }\r\n\r\n search(movie: number): number[] {\r\n\r\n }\r\n\r\n rent(shop: number, movie: number): void {\r\n\r\n }\r\n\r\n drop(shop: number, movie: number): void {\r\n\r\n }\r\n\r\n report(): number[][] {\r\n\r\n }\r\n}\r\n\r\n/**\r\n * Your MovieRentingSystem object will be instantiated and called as such:\r\n * var obj = new MovieRentingSystem(n, entries)\r\n * var param_1 = obj.search(movie)\r\n * obj.rent(shop,movie)\r\n * obj.drop(shop,movie)\r\n * var param_4 = obj.report()\r\n */" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Racket" ,
"langSlug" : "racket" ,
"code" : "(define movie-renting-system%\r\n (class object%\r\n (super-new)\r\n\r\n ; n : exact-integer?\r\n\r\n ; entries : (listof (listof exact-integer?))\r\n (init-field\r\n n\r\n entries)\r\n \r\n ; search : exact-integer? -> (listof exact-integer?)\r\n (define/public (search movie)\r\n\r\n )\r\n ; rent : exact-integer? exact-integer? -> void?\r\n (define/public (rent shop movie)\r\n\r\n )\r\n ; drop : exact-integer? exact-integer? -> void?\r\n (define/public (drop shop movie)\r\n\r\n )\r\n ; report : -> (listof (listof exact-integer?))\r\n (define/public (report)\r\n\r\n )))\r\n\r\n;; Your movie-renting-system% object will be instantiated and called as such:\r\n;; (define obj (new movie-renting-system% [n n] [entries entries]))\r\n;; (define param_1 (send obj search movie))\r\n;; (send obj rent shop movie)\r\n;; (send obj drop shop movie)\r\n;; (define param_4 (send obj report))" ,
"__typename" : "CodeSnippetNode"
}
] ,
2022-03-29 15:21:05 +08:00
"stats" : "{\"totalAccepted\": \"3.8K\", \"totalSubmission\": \"8.9K\", \"totalAcceptedRaw\": 3802, \"totalSubmissionRaw\": 8922, \"acRate\": \"42.6%\"}" ,
2022-03-27 18:27:43 +08:00
"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<integer>\"\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<list<integer>>\"\n }\n }\n ],\n \"return\": {\n \"type\": \"boolean\"\n },\n \"systemdesign\": true,\n \"manual\": false\n}" ,
"judgerAvailable" : true ,
"judgeType" : "large" ,
"mysqlSchemas" : [ ] ,
"enableRunCode" : true ,
"enableTestMode" : false ,
"enableDebugger" : true ,
"envInfo" : "{\"cpp\": [\"C++\", \"<p>Compiled with <code> clang 11 </code> using the latest C++ 17 standard.</p>\\r\\n\\r\\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\\\"https://github.com/google/sanitizers/wiki/AddressSanitizer\\\" target=\\\"_blank\\\">AddressSanitizer</a> is also enabled to help detect out-of-bounds and use-after-free bugs.</p>\\r\\n\\r\\n<p>Most standard library headers are already included automatically for your convenience.</p>\"], \"java\": [\"Java\", \"<p><code> OpenJDK 17 </code>. Java 8 features such as lambda expressions and stream API can be used. </p>\\r\\n\\r\\n<p>Most standard library headers are already included automatically for your convenience.</p>\\r\\n<p>Includes <code>Pair</code> class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.</p>\"], \"python\": [\"Python\", \"<p><code>Python 2.7.12</code>.</p>\\r\\n\\r\\n<p>Most libraries are already imported automatically for your convenience, such as <a href=\\\"https://docs.python.org/2/library/array.html\\\" target=\\\"_blank\\\">array</a>, <a href=\\\"https://docs.python.org/2/library/bisect.html\\\" target=\\\"_blank\\\">bisect</a>, <a href=\\\"https://docs.python.org/2/library/collections.html\\\" target=\\\"_blank\\\">collections</a>. If you need more libraries, you can import it yourself.</p>\\r\\n\\r\\n<p>For Map/TreeMap data structure, you may use <a href=\\\"http://www.grantjenks.com/docs/sortedcontainers/\\\" target=\\\"_blank\\\">sortedcontainers</a> library.</p>\\r\\n\\r\\n<p>Note that Python 2.7 <a href=\\\"https://www.python.org/dev/peps/pep-0373/\\\" target=\\\"_blank\\\">will not be maintained past 2020</a>. For the latest Python, please choose Python3 instead.</p>\"], \"c\": [\"C\", \"<p>Compiled with <code>gcc 8.2</code> using the gnu99 standard.</p>\\r\\n\\r\\n<p>Your code is compiled with level one optimization (<code>-O1</code>). <a href=\\\"https://github.com/google/sanitizers/wiki/AddressSanitizer\\\" target=\\\"_blank\\\">AddressSanitizer</a> is also enabled to help detect out-of-bounds and use-after-free bugs.</p>\\r\\n\\r\\n<p>Most standard library headers are already included automatically for your convenience.</p>\\r\\n\\r\\n<p>For hash table operations, you may use <a href=\\\"https://troydhanson.github.io/uthash/\\\" target=\\\"_blank\\\">uthash</a>. \\\"uthash.h\\\" is included by default. Below are some examples:</p>\\r\\n\\r\\n<p><b>1. Adding an item to a hash.</b>\\r\\n<pre>\\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<p><b>2. Looking up an item in a hash:</b>\\r\\n<pre>\\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<p><b>3. Deleting an item in a hash:</b>\\r\\n<pre>\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n HASH_DEL(users, user); \\r\\n}\\r\\n</pre>\\r\\n</p>\"], \"csharp\": [\"C#\", \"<p><a href=\\\"https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9\\\" target=\\\"_blank\\\">C# 10 with .NET 6 runtime</a></p>\\r\\n\\r\\n<p>Your code is compiled with debug flag enabled (<code>/debug</code>).</p>\"], \"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use <a href=\\\"https://github.com/datastructures-js/priority-queue\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and <a href=\\\" h t t p s :
"libraryUrl" : null ,
"adminUrl" : null ,
"challengeQuestion" : null ,
"__typename" : "QuestionNode"
}
}
}