Sponsored
Use these hints if you're stuck. Try solving on your own first.
Keep the frequency of all pairs (tableNumber, foodItem) using a hashmap.
Sort rows by tableNumber and columns by foodItem, then process the resulted table.
Solve with full IDE support and test cases