1 Star 0 Fork 18

zcc/力扣题库(完整版)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
customers-who-bought-all-products.html 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
小墨 提交于 2023-12-09 18:53 +08:00 . update
<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>&nbsp;</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>&nbsp;</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&nbsp;result format is in the following example.</p>
<p>&nbsp;</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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tutuzhang0/leetcode-problemset.git
git@gitee.com:tutuzhang0/leetcode-problemset.git
tutuzhang0
leetcode-problemset
力扣题库(完整版)
master

搜索帮助