[Java] Easy 100% solution with TreeMap and TreeSet
java\r\nclass Solution {\r\n    public List<List<String>> displayTable(final List<List<String>> orders) {\r\n        final TreeMap<Integer, Map<String, Integer>
```java\r\nclass Solution {\r\n    public List<List<String>> displayTable(final List<List<String>> orders) {\r\n        final TreeMap<Integer, Map<String, Integer>> tables = new TreeMap<>();\r\n        final TreeSet<String> meals = new TreeSet<>();\r\n\r\n        for(final List<String> order : orders) {\r\n            final int tableNum = Integer.valueOf(order.get(1));\r\n\r\n            tables.putIfAbsent(tableNum, new HashMap<>());\r\n\r\n            final Map<String, Integer> table = tables.get(tableNum);\r\n\r\n            table.put(order.get(2), table.getOrDefault(order.get(2), 0) + 1);\r\n\r\n            meals.add(order.get(2));\r\n        }\r\n\r\n        final List<List<String>> result = new ArrayList<>();\r\n\r\n        result.add(new ArrayList<>());\r\n        result.get(0).add("Table");\r\n        result.get(0).addAll(meals);\r\n\r\n        for(final int tableNum : tables.keySet()) {\r\n            final List<String> tableOrders = new ArrayList<>();\r\n            tableOrders.add(String.valueOf(tableNum));\r\n\r\n            final Map<String, Integer> table = tables.get(tableNum);\r\n\r\n            for(int i = 1; i < result.get(0).size(); ++i) {\r\n                final String meal = result.get(0).get(i);\r\n\r\n                tableOrders.add(table.containsKey(meal) ? String.valueOf(table.get(meal)) : "0");\r\n            }\r\n\r\n            result.add(tableOrders);\r\n        }\r\n\r\n        return result;\r\n    }\r\n}\r\n```
['Java']