Simple Java Solution
\tclass Solution {\n\t\tpublic List> displayTable(List> orders) {\n\t\t\tfinal Map> tablesMap = new TreeMap();  \n\t\t\tfinal Set items = new TreeSet();\n\t\t\t
\tclass Solution {\n\t\tpublic List<List<String>> displayTable(List<List<String>> orders) {\n\t\t\tfinal Map<Integer,Map<String,Integer>> tablesMap = new TreeMap();  \n\t\t\tfinal Set<String> items = new TreeSet();\n\t\t\tfinal List<List<String>> res = new ArrayList();\n\n\t\t\tfor(List<String> order : orders) {\n\t\t\t\tfinal int table = Integer.parseInt(order.get(1));\n\t\t\t\tfinal String item = order.get(2);\n\n\t\t\t\tif(!tablesMap.containsKey(table))\n\t\t\t\t\ttablesMap.put(table, new HashMap<String,Integer>());\n\t\t\t\ttablesMap.get(table).put(item, tablesMap.get(table).getOrDefault(item, 0) + 1);\n\t\t\t\titems.add(item);\n\t\t\t}\n\n\t\t\tfor(final int table : tablesMap.keySet()) {\n\t\t\t\tList<String> tableList = new ArrayList();\n\t\t\t\ttableList.add(String.valueOf(table));\n\t\t\t\tfor(String item : items) {\n\t\t\t\t\ttableList.add(String.valueOf(tablesMap.get(table).getOrDefault(item, 0)));\n\t\t\t\t}\n\t\t\t\tres.add(tableList);\n\t\t\t}\n\n\t\t\tfinal List<String> itemsList = new ArrayList<>(items);\n\t\t\titemsList.add(0, "Table");\n\t\t\tres.add(0, itemsList);\n\n\t\t\treturn res;\n\t\t}\n\t}
['Java']