Simple Java Solution with comments
Hope you understand my solution\n\n\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        ArrayList<String> al = n
Hope you understand my solution\n```\n\nclass Solution {\n    public List<List<String>> displayTable(List<List<String>> orders) {\n        ArrayList<String> al = new ArrayList<>(); // to store dishes names\n        HashSet<String> hs = new HashSet<>();  // not to store duplicate items\n        for(List<String> a : orders){\n            if(!hs.contains(a.get(2))){\n                hs.add(a.get(2));\n                al.add(a.get(2));\n            }\n        }\n        Collections.sort(al);  // sorting dishes in ascending order\n        ArrayList<String> header = new ArrayList<>();\n        header.add("Table");\n        HashMap<String,Integer> map = new HashMap<>(); // map to store dishes index\n        for(int i=0;i<al.size();i++){\n            map.put(al.get(i),i);\n            header.add(al.get(i));\n        }\n        TreeMap<Integer,int[]> ans = new TreeMap<>();   // this stores table no as key and dishes array as value\n        for(List<String> a : orders){\n            int num = Integer.parseInt(a.get(1));\n            if(!ans.containsKey(num)){\n                ans.put(num,new int[al.size()]);\n            }\n            int ind = map.get(a.get(2));\n            int arr[] = ans.get(num);\n            arr[ind]++;                              // increment that particular index of dish\n            ans.put(num,arr);                    // store updated array in treemap\n        }\n        List<List<String>> h = new ArrayList<>();\n        h.add(header);\n        for(Integer num : ans.keySet()){        // copying from treemap to arraylist\n            header = new ArrayList<>();\n            String a2 = Integer.toString(num);\n            header.add(a2);\n            int arr[] = ans.get(num);\n            for(int i=0;i<arr.length;i++){\n                String a1 = Integer.toString(arr[i]);\n                header.add(a1);\n            }\n            h.add(header);\n        }\n        return h;\n    }\n}\n```\nHope my code helps and don\'t forget to upvote so that other can also take advantage !!
[]