1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/originData/customers-who-bought-all-products.json
2023-12-09 19:57:46 +08:00

96 lines
9.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"data": {
"question": {
"questionId": "1135",
"questionFrontendId": "1045",
"categoryTitle": "Database",
"boundTopicId": 6079,
"title": "Customers Who Bought All Products",
"titleSlug": "customers-who-bought-all-products",
"content": "<p>Table: <code>Customer</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| customer_id | int |\n| product_key | int |\n+-------------+---------+\nThis table may contain duplicates rows. \n<code>customer_id</code> is not NULL<code>.</code>\nproduct_key is a foreign key (reference column) to <code>Product</code> table.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Product</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| product_key | int |\n+-------------+---------+\nproduct_key is the primary key (column with unique values) for this table.\n</pre>\n\n<p>&nbsp;</p>\n\n<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>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The&nbsp;result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nCustomer table:\n+-------------+-------------+\n| customer_id | product_key |\n+-------------+-------------+\n| 1 | 5 |\n| 2 | 6 |\n| 3 | 5 |\n| 3 | 6 |\n| 1 | 6 |\n+-------------+-------------+\nProduct table:\n+-------------+\n| product_key |\n+-------------+\n| 5 |\n| 6 |\n+-------------+\n<strong>Output:</strong> \n+-------------+\n| customer_id |\n+-------------+\n| 1 |\n| 3 |\n+-------------+\n<strong>Explanation:</strong> \nThe customers who bought all the products (5 and 6) are customers with IDs 1 and 3.\n</pre>\n",
"translatedTitle": "买下所有产品的客户",
"translatedContent": "<p><code>Customer</code>&nbsp;表:</p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| customer_id | int |\n| product_key | int |\n+-------------+---------+\n该表可能包含重复的行。\ncustomer_id 不为 NULL。\nproduct_key 是 Product 表的外键(reference 列)。\n</pre>\n\n<p><code>Product</code>&nbsp;表:</p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| product_key | int |\n+-------------+---------+\nproduct_key 是这张表的主键(具有唯一值的列)。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>编写解决方案,报告&nbsp;<code>Customer</code> 表中购买了 <code>Product</code> 表中所有产品的客户的 id。</p>\n\n<p>返回结果表 <strong>无顺序要求</strong> 。</p>\n\n<p>返回结果格式如下所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>\nCustomer 表:\n+-------------+-------------+\n| customer_id | product_key |\n+-------------+-------------+\n| 1 | 5 |\n| 2 | 6 |\n| 3 | 5 |\n| 3 | 6 |\n| 1 | 6 |\n+-------------+-------------+\nProduct 表:\n+-------------+\n| product_key |\n+-------------+\n| 5 |\n| 6 |\n+-------------+\n<strong>输出:</strong>\n+-------------+\n| customer_id |\n+-------------+\n| 1 |\n| 3 |\n+-------------+\n<strong>解释:</strong>\n购买了所有产品5 和 6的客户的 id 是 1 和 3 。\n</pre>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 98,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef find_customers(customer: pd.DataFrame, product: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"33.4K\", \"totalSubmission\": \"56K\", \"totalAcceptedRaw\": 33371, \"totalSubmissionRaw\": 56008, \"acRate\": \"59.6%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Customer\":[\"customer_id\",\"product_key\"],\"Product\":[\"product_key\"]},\"rows\":{\"Customer\":[[1,5],[2,6],[3,5],[3,6],[1,6]],\"Product\":[[5],[6]]}}",
"metaData": "{\"mysql\":[\"Create table If Not Exists Customer (customer_id int, product_key int)\",\"Create table Product (product_key int)\"],\"mssql\":[\"Create table Customer (customer_id int, product_key int)\",\"Create table Product (product_key int)\"],\"oraclesql\":[\"Create table Customer (customer_id int, product_key int)\",\"Create table Product (product_key int)\"],\"database\":true,\"name\":\"find_customers\",\"pythondata\":[\"Customer = pd.DataFrame([], columns=['customer_id', 'product_key']).astype({'customer_id':'Int64', 'product_key':'Int64'})\",\"Product = pd.DataFrame([], columns=['product_key']).astype({'product_key':'Int64'})\"],\"postgresql\":[\"Create table If Not Exists Customer (customer_id int, product_key int)\\n\",\"Create table Product (product_key int)\"],\"database_schema\":{\"Customer\":{\"customer_id\":\"INT\",\"product_key\":\"INT\"},\"Product\":{\"product_key\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Customer (customer_id int, product_key int)",
"Create table Product (product_key int)",
"Truncate table Customer",
"insert into Customer (customer_id, product_key) values ('1', '5')",
"insert into Customer (customer_id, product_key) values ('2', '6')",
"insert into Customer (customer_id, product_key) values ('3', '5')",
"insert into Customer (customer_id, product_key) values ('3', '6')",
"insert into Customer (customer_id, product_key) values ('1', '6')",
"Truncate table Product",
"insert into Product (product_key) values ('5')",
"insert into Product (product_key) values ('6')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Customer\":[\"customer_id\",\"product_key\"],\"Product\":[\"product_key\"]},\"rows\":{\"Customer\":[[1,5],[2,6],[3,5],[3,6],[1,6]],\"Product\":[[5],[6]]}}",
"__typename": "QuestionNode"
}
}
}