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/originData/group-sold-products-by-the-date.json

98 lines
7.7 KiB
JSON

{
"data": {
"question": {
"questionId": "1625",
"questionFrontendId": "1484",
"boundTopicId": null,
"title": "Group Sold Products By The Date",
"titleSlug": "group-sold-products-by-the-date",
"content": "<p>Table <code>Activities</code>:</p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| sell_date | date |\n| product | varchar |\n+-------------+---------+\nThere is no primary key (column with unique values) for this table. It may contain duplicates.\nEach row of this table contains the product name and the date it was sold in a market.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write a solution to find for each date the number of different products sold and their names.</p>\n\n<p>The sold products names for each date should be sorted lexicographically.</p>\n\n<p>Return the result table ordered by <code>sell_date</code>.</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> \nActivities table:\n+------------+------------+\n| sell_date | product |\n+------------+------------+\n| 2020-05-30 | Headphone |\n| 2020-06-01 | Pencil |\n| 2020-06-02 | Mask |\n| 2020-05-30 | Basketball |\n| 2020-06-01 | Bible |\n| 2020-06-02 | Mask |\n| 2020-05-30 | T-Shirt |\n+------------+------------+\n<strong>Output:</strong> \n+------------+----------+------------------------------+\n| sell_date | num_sold | products |\n+------------+----------+------------------------------+\n| 2020-05-30 | 3 | Basketball,Headphone,T-shirt |\n| 2020-06-01 | 2 | Bible,Pencil |\n| 2020-06-02 | 1 | Mask |\n+------------+----------+------------------------------+\n<strong>Explanation:</strong> \nFor 2020-05-30, Sold items were (Headphone, Basketball, T-shirt), we sort them lexicographically and separate them by a comma.\nFor 2020-06-01, Sold items were (Pencil, Bible), we sort them lexicographically and separate them by a comma.\nFor 2020-06-02, the Sold item is (Mask), we just return it.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 1298,
"dislikes": 92,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Finding the Topic of Each Post\", \"titleSlug\": \"finding-the-topic-of-each-post\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]",
"exampleTestcases": "{\"headers\":{\"Activities\":[\"sell_date\",\"product\"]},\"rows\":{\"Activities\":[[\"2020-05-30\",\"Headphone\"],[\"2020-06-01\",\"Pencil\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"Basketball\"],[\"2020-06-01\",\"Bible\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"T-Shirt\"]]}}",
"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 categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below\n",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"164.6K\", \"totalSubmission\": \"214.6K\", \"totalAcceptedRaw\": 164575, \"totalSubmissionRaw\": 214552, \"acRate\": \"76.7%\"}",
"hints": [],
"solution": {
"id": "2020",
"canSeeDetail": false,
"paidOnly": true,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"Activities\":[\"sell_date\",\"product\"]},\"rows\":{\"Activities\":[[\"2020-05-30\",\"Headphone\"],[\"2020-06-01\",\"Pencil\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"Basketball\"],[\"2020-06-01\",\"Bible\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"T-Shirt\"]]}}",
"metaData": "{\"mysql\": [\"Create table If Not Exists Activities (sell_date date, product varchar(20))\"], \"mssql\": [\"Create table Activities (sell_date date, product varchar(20))\"], \"oraclesql\": [\"Create table Activities (sell_date date, product varchar(20))\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"categorize_products\", \"pythondata\": [\"Activities = pd.DataFrame([], columns=['sell_date', 'product']).astype({'sell_date':'datetime64[ns]', 'product':'object'})\"], \"manual\": false, \"postgresql\": [\"\\nCreate table If Not Exists Activities (sell_date date, product varchar(20))\"], \"database_schema\": {\"Activities\": {\"sell_date\": \"DATE\", \"product\": \"VARCHAR(20)\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Activities (sell_date date, product varchar(20))",
"Truncate table Activities",
"insert into Activities (sell_date, product) values ('2020-05-30', 'Headphone')",
"insert into Activities (sell_date, product) values ('2020-06-01', 'Pencil')",
"insert into Activities (sell_date, product) values ('2020-06-02', 'Mask')",
"insert into Activities (sell_date, product) values ('2020-05-30', 'Basketball')",
"insert into Activities (sell_date, product) values ('2020-06-01', 'Bible')",
"insert into Activities (sell_date, product) values ('2020-06-02', 'Mask')",
"insert into Activities (sell_date, product) values ('2020-05-30', 'T-Shirt')"
],
"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"
}
}
}