Java HashMap ,ArrayList and HashSet Solution
\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        List<String> foodItemList=new ArrayList<>();\n        HashS
```\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        List<String> foodItemList=new ArrayList<>();\n        HashSet<String> foodItemSet=new HashSet<>();\n        List<Integer> tableNoList=new ArrayList<>();\n        HashSet<Integer> tableNoSet=new HashSet<>();\n        \n        HashMap<Integer,HashMap<String,Integer>> orderPerTableMap=new HashMap<>();\n        for(List<String>order:orders){\n            String name=order.get(0);\n            int tno=Integer.parseInt(order.get(1));\n            String foodItem=order.get(2);\n            if(!orderPerTableMap.containsKey(tno)){\n                orderPerTableMap.put(tno,new HashMap<>());\n            }\n            int originalQuantity=orderPerTableMap.get(tno).getOrDefault(foodItem,0);\n            orderPerTableMap.get(tno).put(foodItem,originalQuantity+1);\n            if(!foodItemSet.contains(foodItem)){\n                foodItemSet.add(foodItem);\n                foodItemList.add(foodItem);\n            }\n            if(!tableNoSet.contains(tno)){\n                tableNoSet.add(tno);\n                tableNoList.add(tno);\n            }\n        }\n        Collections.sort(foodItemList);\n        Collections.sort(tableNoList);\n \n        List<List<String>> ans=new ArrayList<>();\n        List<String> t=new ArrayList<>();\n        t.add("Table");\n        t.addAll(foodItemList);\n        ans.add(t);\n        for(int tableNo:tableNoList){\n            List<String> temp=new ArrayList<>();\n            temp.add(tableNo+"");\n            HashMap<String,Integer> quantity=orderPerTableMap.get(tableNo);\n            for(int i=0;i<foodItemList.size();i++){\n                String item=foodItemList.get(i);\n                temp.add(quantity.getOrDefault(item,0)+"");\n            }\n            ans.add(temp);\n        }\n        return ans;\n        \n        \n    }\n}\n```
[]