Question
2.Find top watchlisted movies among friends 1.Implement theAnalyzerclass so that itssolvermethod returns an array of the top four movie titles that have been most often
2.Find top watchlisted movies among friends
1.Implement theAnalyzerclass so that itssolvermethod returns an array of thetop fourmovie titles that have been most often added to a watchlist by friends of a given user.
2.If thesolvermethod doesn't returntop fourmovies, it should return the best N number of movies up to 4, otherwise, it should return an empty list.
3.The resulted list should be sorted by the watch count and then alphabetically.
Example data
Movies collection
{ "title": "The Shawshank Redemption", "duration": "PT142M", "actors": [ "Tim Robbins", "Morgan Freeman", "Bob Gunton" ], "ratings": [], "favorites": [66380, 7001, 9250, 34139], "watchlist": [15291, 51417, 62289, 6146, 71389, 93707] }, { "title": "Pulp Fiction", "duration": "PT154M", "actors": [ "John Travolta", "Uma Thurman", "Samuel L. Jackson" ], "ratings": [], "favorites": [15291, 51417, 62289, 66380, 71389, 93707], "watchlist": [7001, 9250, 34139, 6146] },
Users collection
{ "userId": 15291, "email": , "friends": [7001, 51417, 62289] },
Example output
Given the example data and theuserId62289 your solution should return the following list:
["Schindler's List", "The Lord of the Rings: The Return of the King", "Pulp Fiction", "The Shawshank Redemption"]
The user 62289 has two friends whose ids are 15291 and 7001.Schindler's Listhas been added to the watchlist by both users, so it is the most watchlisted movie.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started