pandas || groupby || T/S: 96% / 85%
Here\'s the plan:\n1. We filter for redundant rows.\n\n2. For each customer count the number of distinct products purchased by each customer.  \n2. We compare t
Here\'s the plan:\n1. We filter for redundant rows.\n\n2. For each customer count the number of distinct products purchased by each customer.  \n2. We compare these counts with `len(product),` the count of the set of distinct products that can be purchased;\n```\nimport pandas as pd\n\ndef find_customers(customer: pd.DataFrame, \n                   product: pd.DataFrame) -> pd.DataFrame:\n    \n    df = customer.drop_duplicates(keep = \'first\'\n                ).groupby(\'customer_id\').count().reset_index()\n\n    return df[df.product_key == len(product)][[\'customer_id\']]\n```\n[https://leetcode.com/problems/customers-who-bought-all-products/submissions/1085527726/?lang=pythondata\n](https://leetcode.com/problems/customers-who-bought-all-products/submissions/1085527726/?lang=pythondata\n)\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*U*), in which *N* ~ `len(customer)` and *U* ~ the number of unique customer ids.
['Pandas']