Practice/Atlassian/Leetcode 1341. Movie Rating
CodingOptional
You are analyzing a film review database containing information about users, movies, and the ratings users have given to movies. Your task is to identify two key pieces of information:
You are given three data structures:
[user_id, user_name] pairs[movie_id, movie_title] pairs[user_id, movie_id, rating, created_date] entries where rating is an integer from 1-5 and created_date is in "YYYY-MM-DD" formatReturn a string with two lines: the user's name on the first line and the movie's title on the second line.
Example 1:
Input: users = [[1, "Alice"], [2, "Bob"], [3, "Carol"]] movies = [[101, "Inception"], [102, "Interstellar"], [103, "Dunkirk"]] ratings = [ [1, 101, 5, "2020-02-15"], [1, 102, 4, "2020-02-16"], [2, 101, 3, "2020-02-10"], [3, 103, 5, "2020-02-20"] ] Output: "Alice\nDunkirk" Explanation: Alice rated 2 distinct movies (Inception and Interstellar), which is more than Bob (1) and Carol (1). For February 2020 ratings: Inception avg=4.0, Interstellar avg=4.0, Dunkirk avg=5.0. Dunkirk has the highest average.
Example 2:
Input: users = [[1, "Zara"], [2, "Aaron"]] movies = [[101, "Zodiac"], [102, "Avatar"]] ratings = [ [1, 101, 5, "2020-02-10"], [2, 102, 5, "2020-02-11"], [1, 102, 3, "2020-01-05"], [2, 101, 4, "2020-02-12"] ] Output: "Aaron\nAvatar" Explanation: Both users rated 2 distinct movies. Aaron comes before Zara alphabetically. For February 2020: Zodiac avg=(5+4)/2=4.5, Avatar avg=5.0. Avatar wins, but if they were tied, Avatar would come before Zodiac alphabetically.