mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 07:51:41 +08:00
update
This commit is contained in:
67
leetcode/problem/customers-who-bought-all-products.html
Normal file
67
leetcode/problem/customers-who-bought-all-products.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<p>Table: <code>Customer</code></p>
|
||||
|
||||
<pre>
|
||||
+-------------+---------+
|
||||
| Column Name | Type |
|
||||
+-------------+---------+
|
||||
| customer_id | int |
|
||||
| product_key | int |
|
||||
+-------------+---------+
|
||||
This table may contain duplicates rows.
|
||||
<code>customer_id</code> is not NULL<code>.</code>
|
||||
product_key is a foreign key (reference column) to <code>Product</code> table.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>Table: <code>Product</code></p>
|
||||
|
||||
<pre>
|
||||
+-------------+---------+
|
||||
| Column Name | Type |
|
||||
+-------------+---------+
|
||||
| product_key | int |
|
||||
+-------------+---------+
|
||||
product_key is the primary key (column with unique values) for this table.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>Write a solution to report the customer ids from the <code>Customer</code> table that bought all the products in the <code>Product</code> table.</p>
|
||||
|
||||
<p>Return the result table in <strong>any order</strong>.</p>
|
||||
|
||||
<p>The result format is in the following example.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong>
|
||||
Customer table:
|
||||
+-------------+-------------+
|
||||
| customer_id | product_key |
|
||||
+-------------+-------------+
|
||||
| 1 | 5 |
|
||||
| 2 | 6 |
|
||||
| 3 | 5 |
|
||||
| 3 | 6 |
|
||||
| 1 | 6 |
|
||||
+-------------+-------------+
|
||||
Product table:
|
||||
+-------------+
|
||||
| product_key |
|
||||
+-------------+
|
||||
| 5 |
|
||||
| 6 |
|
||||
+-------------+
|
||||
<strong>Output:</strong>
|
||||
+-------------+
|
||||
| customer_id |
|
||||
+-------------+
|
||||
| 1 |
|
||||
| 3 |
|
||||
+-------------+
|
||||
<strong>Explanation:</strong>
|
||||
The customers who bought all the products (5 and 6) are customers with IDs 1 and 3.
|
||||
</pre>
|
Reference in New Issue
Block a user