Simple cpp solution using maps with detailed explanation.
\n        set<string> items;   \n        //Table Number <item, count of item>;\n        map<int, map<string, int>> mp;\n        \n        vector<vector<string>>
```\n        set<string> items;   \n        //Table Number <item, count of item>;\n        map<int, map<string, int>> mp;\n        \n        vector<vector<string>> res;\n        vector<string> temp;\n        \n        //First get the items list and table numbers\n        for(auto list : orders)\n        {\n            items.insert(list[2]);\n            mp[stoi(list[1])][list[2]]++;\n        }\n        \n        //Push first row. Table followed by all items list\n        temp.push_back("Table");\n        for(auto itr = items.begin(); itr != items.end(); itr++)\n            temp.push_back(*itr);\n        \n        res.push_back(temp);\n        \n        //Now you have first row. Next iterate through the map and push all other values corresponding to that table number\n        for(auto itr2 = mp.begin(); itr2 != mp.end(); itr2++)\n        {\n            temp.clear();\n            //Push the table number\n            temp.push_back(to_string(itr2->first));\n            \n            //If you can find a food entry, push that value, else push 0\n            for(auto itr1 = items.begin(); itr1 != items.end(); itr1++)\n            {\n                if(itr2->second.find(*itr1) != itr2->second.end())\n                    temp.push_back(to_string(itr2->second[*itr1]));\n                else\n                    temp.push_back("0");\n            }\n            res.push_back(temp);\n        }\n        \n        return res;\n    }\n```
[]