4 lines Python with picture
Solution A:\n\ntf_cnt: table/food tallies\nf_row:  a sorted list of foods\nt_col: a sorted list of table numbers\n\n\n\n\nclass Solution:\n    def displayTable(
**Solution A:**\n\n**tf**_cnt: **t**able/**f**ood tallies\n**f**_row:  a sorted list of **f**oods\n**t**_col: a sorted list of **t**able numbers\n\n![image](https://assets.leetcode.com/users/_xavier_/image_1587430055.png)\n\n```\nclass Solution:\n    def displayTable(self, orders):\n        tf_cnt = collections.Counter([(T, F) for _, T, F in orders])\n        f_row  = sorted(set(F for _, _, F in orders))\n        t_col  = sorted(set(T for _, T, _ in orders), key=int)\n        return   [["Table"] + f_row] + [[T] + [str(tf_cnt[T, F]) for F in f_row] for T in t_col]\n```\t\t\n\n**Solution B:**\n\n**1)** d is a list of tuples each being a unique combination of (Table, Food) \n**2)** tables is the sorted list of all Table numbers\n**3)** title_row is the title row of the resultset (ans). \n\t\t\t**Note**: The first column of this row (being the word "Table") is added later (after the loop) to prevent unnecesary usage of enumerate or costly **title_row[1:]** inside the comprehension. \n**4)** Each data_row is a row of the resultset (ans)\n\n```\nclass Solution:\n    def displayTable(self, orders):\n        ans, d = [], defaultdict(int)\n        for _, T, F in orders:\n            d[(T, F)] += 1\n        title_row = sorted(set(F for _, _, F in orders))\n        tables = sorted(set(T for _, T, _ in orders), key=int)\n        for T in tables:\n            data_row = [T]\n            data_row.extend([str(d[T, F]) for F in title_row])\n            ans.append(data_row)\n        title_row.insert(0, "Table")\n        ans.insert(0, title_row)\n        return ans\n```
[]