Short and concise Java solution using TreeMap and Treeset
\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        List<List<String>> res = new ArrayList<>();\n        TreeMa
```\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        List<List<String>> res = new ArrayList<>();\n        TreeMap<Integer, Map<String, Integer>> map = new TreeMap<>();\n        TreeSet<String> foods = new TreeSet<>();\n        for(List<String> curr : orders){\n            int no = Integer.parseInt(curr.get(1));\n            String food = curr.get(2);\n            Map<String, Integer> tmap = map.getOrDefault(no, new HashMap<>());\n            tmap.put(food, tmap.getOrDefault(food, 0) + 1);\n            map.putIfAbsent(no, tmap);\n            foods.add(food);\n        }\n        \n        List<String> header = new ArrayList<>();\n        header.add("Table");\n        for(String food : foods){\n            header.add(food);\n        }\n        res.add(header);\n        for(int tableNo : map.keySet()){\n            Map<String, Integer> tmap = map.get(tableNo);\n            List<String> list = new ArrayList<>();\n            list.add("" + tableNo);\n            for(String food : foods){\n                list.add("" + tmap.getOrDefault(food, 0));\n            }\n            res.add(list);\n        }\n        \n        return res;\n    }\n}\n```
[]