From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/design_food_rating_sys.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 other/design_food_rating_sys.cpp (limited to 'other/design_food_rating_sys.cpp') diff --git a/other/design_food_rating_sys.cpp b/other/design_food_rating_sys.cpp deleted file mode 100644 index bdfef0c..0000000 --- a/other/design_food_rating_sys.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// 2353. Design a Food Rating System -#include "leetcode.h" - -/* - * design a food rating system that can do the following: - * - modify the rating of a food item listed in the system - * - return the highest rated food item for a type of cuisine in the system - * implement the 'FoodRatings' class. note that a string 'x' is - * lexicographically smaller than string 'y' if 'x' comes before 'y' in - * dictionary order, that is, either 'x' is a prefix of 'y' or if 'i' is the - * first position such that 'x[i] != y[i], then x[i] comes beofre y[i] in - * alpabetic order - */ - -class FoodRatings { -private: - unordered_map f2c; - unordered_map f2r; - unordered_map>> c2r; - -public: - FoodRatings(vector &foods, vector &cuisines, - vector &ratings) { - for (int i = 0; i < foods.size(); i++) { - f2c[foods[i]] = cuisines[i]; - f2r[foods[i]] = ratings[i]; - c2r[cuisines[i]].emplace(-ratings[i], foods[i]); - } - } - - void changeRating(string food, int newRating) { - int r = exchange(f2r[food], newRating); - auto &c = f2c[food]; - auto it = c2r.find(c); - it->second.erase({-r, food}); - it->second.emplace(-newRating, food); - } - - string highestRated(string cuisine) { return begin(c2r[cuisine])->second; } -}; -- cgit v1.2.3