https://leetcode.com/problems/design-a-food-rating-system/


Timeout 


```python
class FoodRatings:
    def __init__(self, foods: List[str], cuisines: List[str], ratings: List[int]):
        #2023.03.22 07:55
        self.big_dict = {}
        self.food_to_food_type_dict = {}
        for index, _ in enumerate(foods):
            food = foods[index]
            food_type = cuisines[index]
            rating = ratings[index]

            self.food_to_food_type_dict[food] = food_type

            if self.big_dict.get(food_type) == None:
                self.big_dict[food_type] = {}

            if self.big_dict.get(food_type).get(food) == None:
                self.big_dict[food_type][food] = {
                    "rating": rating,
                    "times": 1
                }
            else:
                new_times = self.big_dict[food_type][food]["times"] + 1
                new_rate = (self.big_dict[food_type][food]["rating"] + rating) / new_times
                self.big_dict[food_type][food] = {
                    "rating": new_rate,
                    "times": new_times
                }
        #2023.03.22 08:20

    def changeRating(self, food: str, newRating: int) -> None:
        food_type = self.food_to_food_type_dict[food]
        new_times = self.big_dict[food_type][food]["times"] + 1
        # new_rate = (self.big_dict[food_type][food]["rating"] + newRating) / new_times
        new_rate = newRating
        self.big_dict[food_type][food] = {
            "rating": new_rate,
            "times": new_times
        }

    def highestRated(self, cuisine: str) -> str:
        highest_rate = -1
        highest_rate_food = []
        for food, item in self.big_dict[cuisine].items():
            if item["rating"] > highest_rate:
                highest_rate = item["rating"]
                highest_rate_food = [food]
            if item["rating"] == highest_rate:
                highest_rate_food.append(food)
        highest_rate_food.sort()
        return highest_rate_food[0]
```
