Java TreeSet, Map, and ArrayList
Use TreeMap for sorted food names.\nMap to store the food cnts for each table;\n\npublic List<List<String>> displayTable(List<List<String>> orders) {\n        M
Use TreeMap for sorted food names.\nMap to store the food cnts for each table;\n```\npublic List<List<String>> displayTable(List<List<String>> orders) {\n        Map<Integer, Map<String, Integer>> map = new HashMap<>();\n        Set<String> set = new TreeSet<>();\n        for (List<String> od : orders) {\n            int tab = Integer.parseInt(od.get(1));\n            String dish = od.get(2);\n            map.computeIfAbsent(tab, k -> new HashMap<>());\n            map.get(tab).put(dish, map.get(tab).getOrDefault(dish, 0) + 1);\n            set.add(dish);\n        }\n        int len = Collections.max(map.keySet());\n        List<String> cap = new ArrayList<>();\n        cap.add("Table");\n        for (String dish : set) cap.add(dish);\n        List<List<String>> res = new ArrayList<>();\n        res.add(cap);\n        for (int i = 0; i <= len; i++) {\n            if (!map.containsKey(i)) continue;\n            List<String> list = new ArrayList();\n            list.add(String.valueOf(i));\n            Map<String, Integer> ds = map.get(i);\n            for (int j = 1; j < cap.size(); j++) {\n                list.add(String.valueOf(ds.getOrDefault(cap.get(j), 0)));\n            }\n            res.add(list);\n        }\n        return res;\n    }\n```
[]