mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
100 lines
7.3 KiB
JSON
100 lines
7.3 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "1135",
|
|
"questionFrontendId": "1045",
|
|
"boundTopicId": null,
|
|
"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> </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> </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 result format is in the following example.</p>\n\n<p> </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": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Medium",
|
|
"likes": 592,
|
|
"dislikes": 58,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"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]]}}",
|
|
"categoryTitle": "Database",
|
|
"contributors": [],
|
|
"topicTags": [
|
|
{
|
|
"name": "Database",
|
|
"slug": "database",
|
|
"translatedName": null,
|
|
"__typename": "TopicTagNode"
|
|
}
|
|
],
|
|
"companyTagStats": null,
|
|
"codeSnippets": [
|
|
{
|
|
"lang": "MySQL",
|
|
"langSlug": "mysql",
|
|
"code": "# Write your MySQL query statement below\n",
|
|
"__typename": "CodeSnippetNode"
|
|
},
|
|
{
|
|
"lang": "MS SQL Server",
|
|
"langSlug": "mssql",
|
|
"code": "/* Write your T-SQL query statement below */\n",
|
|
"__typename": "CodeSnippetNode"
|
|
},
|
|
{
|
|
"lang": "Oracle",
|
|
"langSlug": "oraclesql",
|
|
"code": "/* Write your PL/SQL query statement below */\n",
|
|
"__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\n",
|
|
"__typename": "CodeSnippetNode"
|
|
}
|
|
],
|
|
"stats": "{\"totalAccepted\": \"105.3K\", \"totalSubmission\": \"171.8K\", \"totalAcceptedRaw\": 105318, \"totalSubmissionRaw\": 171769, \"acRate\": \"61.3%\"}",
|
|
"hints": [],
|
|
"solution": {
|
|
"id": "1615",
|
|
"canSeeDetail": false,
|
|
"paidOnly": true,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"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,
|
|
"enableTestMode": false,
|
|
"enableDebugger": false,
|
|
"envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"], \"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"], \"postgresql\": [\"PostgreSQL\", \"<p>PostgreSQL 16</p>\"]}",
|
|
"libraryUrl": null,
|
|
"adminUrl": null,
|
|
"challengeQuestion": null,
|
|
"__typename": "QuestionNode"
|
|
}
|
|
}
|
|
} |