clean code using Dict of Dict
\r\nclass Solution:\r\n    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:\r\n        # iterate through all orders and get the unique food i
```\r\nclass Solution:\r\n    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:\r\n        # iterate through all orders and get the unique food items\r\n        # in same manner get table numbers\r\n        food_items, table_numbers = set(), set()\r\n\r\n        for order in orders:\r\n            cust_name = order[0]\r\n            table_num = order[1]\r\n            food_item = order[2]\r\n\r\n            food_items.add(food_item)\r\n            table_numbers.add(table_num)\r\n\r\n        # create a map of map such that main index will be the table number and then inner dictionary will contains the frequency of the food items for that table number\r\n        map_ = {}\r\n\r\n        for order in orders:\r\n            cust_name = order[0]\r\n            table_num = order[1]\r\n            food_item = order[2]\r\n\r\n            if table_num not in map_:\r\n                map_[table_num] = { food_item : 1 }\r\n            elif table_num in map_:            \r\n                map_[table_num][food_item] = map_[table_num].setdefault(food_item, 0) + 1\r\n\r\n        food_items = sorted(list(food_items))\r\n        table_numbers = sorted(list(table_numbers),key=lambda x:int(x))\r\n\r\n        header = [\'Table\'] + food_items\r\n        display_table = []\r\n        display_table.append(header)\r\n\r\n        for table_num in table_numbers:\r\n            row = [str(table_num)]\r\n\r\n            for food_item in food_items:\r\n                if food_item not in map_[table_num]:\r\n                    row.append(\'0\')\r\n                elif food_item in map_[table_num]:\r\n                    row.append(str(map_[table_num][food_item]))\r\n            display_table.append(row)\r\n\r\n        return display_table\r\n```
['Python3']