Design a Food Rating System | Clean Approach | Leetcode-2353
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 14th Video of our Playlist "Design Data Structure".
In this video we will try to solve a very good Design problem - Design a Food Rating System (Leetcode - 2353).
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Design a Food Rating System
Company Tags : AMAZON
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Design/Design%20a%20Food%20Rating%20System.cpp
Leetcode Link : https://leetcode.com/problems/design-a-food-rating-system/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Approach Summary :
The class uses three unordered maps to store information about food ratings, the cuisine to which each food belongs, and the individual ratings of each food. The constructor initializes these maps by iterating over provided vectors of food names, cuisines, and ratings. The changeRating method allows for updating the rating of a specific food item. It retrieves the cuisine of the food, removes the old rating entry from the corresponding set (ordered by the negative of ratings), inserts the new rating, and updates the rating in the food_rating map. The highestRated method returns the name of the highest-rated food for a given cuisine. It achieves this by accessing the first element of the set of ratings for the specified cuisine, taking advantage of the set's ordering based on the negative of ratings. The method includes a comment explaining the decision to use negative ratings and the importance of lexicographical ordering in cases of equal ratings. This approach ensures consistent and predictable results when dealing with ties in ratings.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa