mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-03 22:42:52 +08:00
update
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2769",
|
||||
"questionFrontendId": "2675",
|
||||
"boundTopicId": null,
|
||||
"title": "Array of Objects to Matrix",
|
||||
"titleSlug": "array-of-objects-to-matrix",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Hard",
|
||||
"likes": 130,
|
||||
"dislikes": 72,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"JSON Deep Equal\", \"titleSlug\": \"json-deep-equal\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Convert Object to JSON String\", \"titleSlug\": \"convert-object-to-json-string\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "[{\"b\":1,\"a\":2},{\"b\":3,\"a\":4}]\n[{\"a\":1,\"b\":2},{\"c\":3,\"d\":4},{}]\n[{\"a\":{\"b\":1,\"c\":2}},{\"a\":{\"b\":3,\"d\":4}}]\n[[{\"a\":null}],[{\"b\":true}],[{\"c\":\"x\"}]]\n[{},{},{}]",
|
||||
"categoryTitle": "JavaScript",
|
||||
"contributors": [],
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"5.8K\", \"totalSubmission\": \"8.3K\", \"totalAcceptedRaw\": 5761, \"totalSubmissionRaw\": 8290, \"acRate\": \"69.5%\"}",
|
||||
"hints": [
|
||||
"How could you split the problem up into sub-problems?",
|
||||
"1.) Write a function that converts a single object into a dictionary that maps the path name to values. You can solve this recursively by keeping track of current path list.",
|
||||
"2.) Write a function that converts a list of dictionaries into a matrix. Start by creating a list of all possible paths in any of the dictionaries. This will represent the columns."
|
||||
],
|
||||
"solution": {
|
||||
"id": "1912",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "[{\"b\":1,\"a\":2},{\"b\":3,\"a\":4}]",
|
||||
"metaData": "{\n \"name\": \"jsonToMatrix\",\n \"params\": [\n {\n \"name\": \"arr\",\n \"type\": \"string\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n },\n \"languages\": [\n \"typescript\",\n \"javascript\"\n ],\n \"manual\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"enableTestMode": false,
|
||||
"enableDebugger": false,
|
||||
"envInfo": "{\"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use 5.3.0 version of <a href=\\\"https://github.com/datastructures-js/priority-queue/tree/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and 4.2.1 version of <a href=\\\"https://github.com/datastructures-js/queue/tree/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\">datastructures-js/queue</a>.</p>\"], \"typescript\": [\"Typescript\", \"<p><code>TypeScript 5.1.6, Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES2022 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\"]}",
|
||||
"libraryUrl": null,
|
||||
"adminUrl": null,
|
||||
"challengeQuestion": null,
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
53
leetcode/originData/[no content]curry.json
Normal file
53
leetcode/originData/[no content]curry.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2740",
|
||||
"questionFrontendId": "2632",
|
||||
"boundTopicId": null,
|
||||
"title": "Curry",
|
||||
"titleSlug": "curry",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 332,
|
||||
"dislikes": 34,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Memoize\", \"titleSlug\": \"memoize\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Memoize II\", \"titleSlug\": \"memoize-ii\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "function sum(a, b, c) { return a + b + c; }\n[[1],[2],[3]]\nfunction sum(a, b, c) { return a + b + c; }\n[[1,2],[3]]\nfunction sum(a, b, c) { return a + b + c; }\n[[],[],[1,2,3]]\nfunction life() { return 42; }\n[[]]",
|
||||
"categoryTitle": "JavaScript",
|
||||
"contributors": [],
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"15.1K\", \"totalSubmission\": \"16.9K\", \"totalAcceptedRaw\": 15129, \"totalSubmissionRaw\": 16937, \"acRate\": \"89.3%\"}",
|
||||
"hints": [
|
||||
"You can access the count of parameters expected to passed into a function with \"fn.length\".",
|
||||
"You can use recursion. If the length of params passed is equal to fn.length, you are done. Just pass those params to fn. Otherwise return a function that is includes the previous passed params plus the new params. The new function should contain a recursive call to curry()."
|
||||
],
|
||||
"solution": {
|
||||
"id": "1897",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "function sum(a, b, c) { return a + b + c; }\n[[1],[2],[3]]",
|
||||
"metaData": "{\n \"name\": \"curry\",\n \"params\": [\n {\n \"name\": \"fn\",\n \"type\": \"string\"\n },\n {\n \"type\": \"integer[][]\",\n \"name\": \"inputs\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"enableTestMode": false,
|
||||
"enableDebugger": false,
|
||||
"envInfo": "{\"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use 5.3.0 version of <a href=\\\"https://github.com/datastructures-js/priority-queue/tree/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and 4.2.1 version of <a href=\\\"https://github.com/datastructures-js/queue/tree/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\">datastructures-js/queue</a>.</p>\"], \"typescript\": [\"Typescript\", \"<p><code>TypeScript 5.1.6, Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES2022 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\"]}",
|
||||
"libraryUrl": null,
|
||||
"adminUrl": null,
|
||||
"challengeQuestion": null,
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2774",
|
||||
"questionFrontendId": "2700",
|
||||
"boundTopicId": null,
|
||||
"title": "Differences Between Two Objects",
|
||||
"titleSlug": "differences-between-two-objects",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 132,
|
||||
"dislikes": 19,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"JSON Deep Equal\", \"titleSlug\": \"json-deep-equal\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Convert Object to JSON String\", \"titleSlug\": \"convert-object-to-json-string\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{}\n{\"a\": 1, \"b\": 2}\n{\"a\": 1, \"v\": 3, \"x\": [], \"z\": {\"a\": null}}\n{\"a\": 2, \"v\": 4, \"x\": [], \"z\": {\"a\": 2}}\n{\"a\": 5, \"v\": 6, \"z\": [1,2,4, [2,5,7]]}\n{\"a\": 5, \"v\": 7, \"z\": [1,2,3, [1]]}\n{\"a\":{\"b\":1}}\n{\"a\":[5]}\n{\"a\": [1, 2, {}],\"b\": false}\n{\"b\": false, \"a\": [1, 2, {}]}",
|
||||
"categoryTitle": "JavaScript",
|
||||
"contributors": [],
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"5.7K\", \"totalSubmission\": \"7K\", \"totalAcceptedRaw\": 5737, \"totalSubmissionRaw\": 7038, \"acRate\": \"81.5%\"}",
|
||||
"hints": [
|
||||
"Find the intersection of the keys/indices on the two arrays/objects.",
|
||||
"Analyze the data structure recursively.",
|
||||
"For each key in the intersection, omit if there are no differences in the leaves. Otherwise return the difference."
|
||||
],
|
||||
"solution": {
|
||||
"id": "1914",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{}\n{\"a\": 1, \"b\": 2}",
|
||||
"metaData": "{\n \"name\": \"objDiff\",\n \"params\": [\n {\n \"name\": \"obj1\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"obj2\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"enableTestMode": false,
|
||||
"enableDebugger": false,
|
||||
"envInfo": "{\"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use 5.3.0 version of <a href=\\\"https://github.com/datastructures-js/priority-queue/tree/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and 4.2.1 version of <a href=\\\"https://github.com/datastructures-js/queue/tree/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\">datastructures-js/queue</a>.</p>\"], \"typescript\": [\"Typescript\", \"<p><code>TypeScript 5.1.6, Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES2022 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\"]}",
|
||||
"libraryUrl": null,
|
||||
"adminUrl": null,
|
||||
"challengeQuestion": null,
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
53
leetcode/originData/[no content]promise-pool.json
Normal file
53
leetcode/originData/[no content]promise-pool.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2750",
|
||||
"questionFrontendId": "2636",
|
||||
"boundTopicId": null,
|
||||
"title": "Promise Pool",
|
||||
"titleSlug": "promise-pool",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 273,
|
||||
"dislikes": 25,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Sleep\", \"titleSlug\": \"sleep\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Promise Time Limit\", \"titleSlug\": \"promise-time-limit\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Cache With Time Limit\", \"titleSlug\": \"cache-with-time-limit\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Throttle\", \"titleSlug\": \"throttle\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "[() => new Promise(res => setTimeout(res, 300)), () => new Promise(res => setTimeout(res, 400)), () => new Promise(res => setTimeout(res, 200))]\n2\n[() => new Promise(res => setTimeout(res, 300)), () => new Promise(res => setTimeout(res, 400)), () => new Promise(res => setTimeout(res, 200))]\n5\n[() => new Promise(res => setTimeout(res, 300)), () => new Promise(res => setTimeout(res, 400)), () => new Promise(res => setTimeout(res, 200))]\n1",
|
||||
"categoryTitle": "JavaScript",
|
||||
"contributors": [],
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"10.9K\", \"totalSubmission\": \"13.5K\", \"totalAcceptedRaw\": 10934, \"totalSubmissionRaw\": 13536, \"acRate\": \"80.8%\"}",
|
||||
"hints": [
|
||||
"Initially execute all the functions until the queue fills up.",
|
||||
"Every time a function resolves, add a new promise to the queue if possible."
|
||||
],
|
||||
"solution": {
|
||||
"id": "1901",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "[() => new Promise(res => setTimeout(res, 300)), () => new Promise(res => setTimeout(res, 400)), () => new Promise(res => setTimeout(res, 200))]\n2",
|
||||
"metaData": "{\n \"name\": \"promisePool\",\n \"params\": [\n {\n \"name\": \"getFunctions\",\n \"type\": \"string\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"n\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"enableTestMode": false,
|
||||
"enableDebugger": false,
|
||||
"envInfo": "{\"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use 5.3.0 version of <a href=\\\"https://github.com/datastructures-js/priority-queue/tree/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and 4.2.1 version of <a href=\\\"https://github.com/datastructures-js/queue/tree/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\">datastructures-js/queue</a>.</p>\"], \"typescript\": [\"Typescript\", \"<p><code>TypeScript 5.1.6, Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES2022 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\"]}",
|
||||
"libraryUrl": null,
|
||||
"adminUrl": null,
|
||||
"challengeQuestion": null,
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
54
leetcode/originData/[no content]throttle.json
Normal file
54
leetcode/originData/[no content]throttle.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2771",
|
||||
"questionFrontendId": "2676",
|
||||
"boundTopicId": null,
|
||||
"title": "Throttle",
|
||||
"titleSlug": "throttle",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 156,
|
||||
"dislikes": 27,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Debounce\", \"titleSlug\": \"debounce\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Promise Time Limit\", \"titleSlug\": \"promise-time-limit\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Promise Pool\", \"titleSlug\": \"promise-pool\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "100\n[{\"t\":20,\"inputs\":[1]}]\n50\n[{\"t\":50,\"inputs\":[1]},{\"t\":75,\"inputs\":[2]}]\n70\n[{\"t\":50,\"inputs\":[1]},{\"t\":75,\"inputs\":[2]},{\"t\":90,\"inputs\":[8]},{\"t\": 140, \"inputs\":[5,7]},{\"t\": 300, \"inputs\": [9,4]}]",
|
||||
"categoryTitle": "JavaScript",
|
||||
"contributors": [],
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"7.9K\", \"totalSubmission\": \"9.5K\", \"totalAcceptedRaw\": 7916, \"totalSubmissionRaw\": 9511, \"acRate\": \"83.2%\"}",
|
||||
"hints": [
|
||||
"Store a variable for currArguments.",
|
||||
"If no timeout is in progress, immediately execute the function and create a timeout. If a timeout is in progress, set the currArguments to the new arguments.",
|
||||
"When the timeout is done: if currArguments is null, do nothing. Otherwise, execute the function with currArguments and create another timeout."
|
||||
],
|
||||
"solution": {
|
||||
"id": "1908",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "100\n[{\"t\":20,\"inputs\":[1]}]",
|
||||
"metaData": "{\n \"name\": \"throttle\",\n \"params\": [\n {\n \"name\": \"fn\",\n \"type\": \"string\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"t\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"enableTestMode": false,
|
||||
"enableDebugger": false,
|
||||
"envInfo": "{\"javascript\": [\"JavaScript\", \"<p><code>Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES6 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\\r\\n\\r\\n<p>For Priority Queue / Queue data structures, you may use 5.3.0 version of <a href=\\\"https://github.com/datastructures-js/priority-queue/tree/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\">datastructures-js/priority-queue</a> and 4.2.1 version of <a href=\\\"https://github.com/datastructures-js/queue/tree/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\">datastructures-js/queue</a>.</p>\"], \"typescript\": [\"Typescript\", \"<p><code>TypeScript 5.1.6, Node.js 16.13.2</code>.</p>\\r\\n\\r\\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\\\"http://node.green/\\\" target=\\\"_blank\\\">new ES2022 features</a>.</p>\\r\\n\\r\\n<p><a href=\\\"https://lodash.com\\\" target=\\\"_blank\\\">lodash.js</a> library is included by default.</p>\"]}",
|
||||
"libraryUrl": null,
|
||||
"adminUrl": null,
|
||||
"challengeQuestion": null,
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
101
leetcode/originData/average-selling-price.json
Normal file
101
leetcode/originData/average-selling-price.json
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1390",
|
||||
"questionFrontendId": "1251",
|
||||
"boundTopicId": null,
|
||||
"title": "Average Selling Price",
|
||||
"titleSlug": "average-selling-price",
|
||||
"content": "<p>Table: <code>Prices</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| product_id | int |\n| start_date | date |\n| end_date | date |\n| price | int |\n+---------------+---------+\n(product_id, start_date, end_date) is the primary key (combination of columns with unique values) for this table.\nEach row of this table indicates the price of the product_id in the period from start_date to end_date.\nFor each product_id there will be no two overlapping periods. That means there will be no two intersecting periods for the same product_id.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>UnitsSold</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| product_id | int |\n| purchase_date | date |\n| units | int |\n+---------------+---------+\nThis table may contain duplicate rows.\nEach row of this table indicates the date, units, and product_id of each product sold. \n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the average selling price for each product. <code>average_price</code> should be <strong>rounded to 2 decimal places</strong>.</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> \nPrices table:\n+------------+------------+------------+--------+\n| product_id | start_date | end_date | price |\n+------------+------------+------------+--------+\n| 1 | 2019-02-17 | 2019-02-28 | 5 |\n| 1 | 2019-03-01 | 2019-03-22 | 20 |\n| 2 | 2019-02-01 | 2019-02-20 | 15 |\n| 2 | 2019-02-21 | 2019-03-31 | 30 |\n+------------+------------+------------+--------+\nUnitsSold table:\n+------------+---------------+-------+\n| product_id | purchase_date | units |\n+------------+---------------+-------+\n| 1 | 2019-02-25 | 100 |\n| 1 | 2019-03-01 | 15 |\n| 2 | 2019-02-10 | 200 |\n| 2 | 2019-03-22 | 30 |\n+------------+---------------+-------+\n<strong>Output:</strong> \n+------------+---------------+\n| product_id | average_price |\n+------------+---------------+\n| 1 | 6.96 |\n| 2 | 16.96 |\n+------------+---------------+\n<strong>Explanation:</strong> \nAverage selling price = Total Price of Product / Number of products sold.\nAverage selling price for product 1 = ((100 * 5) + (15 * 20)) / 115 = 6.96\nAverage selling price for product 2 = ((200 * 15) + (30 * 30)) / 230 = 16.96\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 860,
|
||||
"dislikes": 89,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Prices\":[\"product_id\",\"start_date\",\"end_date\",\"price\"],\"UnitsSold\":[\"product_id\",\"purchase_date\",\"units\"]},\"rows\":{\"Prices\":[[1,\"2019-02-17\",\"2019-02-28\",5],[1,\"2019-03-01\",\"2019-03-22\",20],[2,\"2019-02-01\",\"2019-02-20\",15],[2,\"2019-02-21\",\"2019-03-31\",30]],\"UnitsSold\":[[1,\"2019-02-25\",100],[1,\"2019-03-01\",15],[2,\"2019-02-10\",200],[2,\"2019-03-22\",30]]}}",
|
||||
"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 average_selling_price(prices: pd.DataFrame, units_sold: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"133.2K\", \"totalSubmission\": \"261.7K\", \"totalAcceptedRaw\": 133231, \"totalSubmissionRaw\": 261739, \"acRate\": \"50.9%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2138",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Prices\":[\"product_id\",\"start_date\",\"end_date\",\"price\"],\"UnitsSold\":[\"product_id\",\"purchase_date\",\"units\"]},\"rows\":{\"Prices\":[[1,\"2019-02-17\",\"2019-02-28\",5],[1,\"2019-03-01\",\"2019-03-22\",20],[2,\"2019-02-01\",\"2019-02-20\",15],[2,\"2019-02-21\",\"2019-03-31\",30]],\"UnitsSold\":[[1,\"2019-02-25\",100],[1,\"2019-03-01\",15],[2,\"2019-02-10\",200],[2,\"2019-03-22\",30]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Prices (product_id int, start_date date, end_date date, price int)\", \"Create table If Not Exists UnitsSold (product_id int, purchase_date date, units int)\"], \"mssql\": [\"Create table Prices (product_id int, start_date date, end_date date, price int)\", \"Create table UnitsSold (product_id int, purchase_date date, units int)\"], \"oraclesql\": [\"Create table Prices (product_id int, start_date date, end_date date, price int)\", \"Create table UnitsSold (product_id int, purchase_date date, units int)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"average_selling_price\", \"pythondata\": [\"Prices = pd.DataFrame([], columns=['product_id', 'start_date', 'end_date', 'price']).astype({'product_id':'Int64', 'start_date':'datetime64[ns]', 'end_date':'datetime64[ns]', 'price':'Int64'})\", \"UnitsSold = pd.DataFrame([], columns=['product_id', 'purchase_date', 'units']).astype({'product_id':'Int64', 'purchase_date':'datetime64[ns]', 'units':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Prices (product_id int, start_date date, end_date date, price int)\\n\", \"Create table If Not Exists UnitsSold (product_id int, purchase_date date, units int)\"], \"database_schema\": {\"Prices\": {\"product_id\": \"INT\", \"start_date\": \"DATE\", \"end_date\": \"DATE\", \"price\": \"INT\"}, \"UnitsSold\": {\"product_id\": \"INT\", \"purchase_date\": \"DATE\", \"units\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Prices (product_id int, start_date date, end_date date, price int)",
|
||||
"Create table If Not Exists UnitsSold (product_id int, purchase_date date, units int)",
|
||||
"Truncate table Prices",
|
||||
"insert into Prices (product_id, start_date, end_date, price) values ('1', '2019-02-17', '2019-02-28', '5')",
|
||||
"insert into Prices (product_id, start_date, end_date, price) values ('1', '2019-03-01', '2019-03-22', '20')",
|
||||
"insert into Prices (product_id, start_date, end_date, price) values ('2', '2019-02-01', '2019-02-20', '15')",
|
||||
"insert into Prices (product_id, start_date, end_date, price) values ('2', '2019-02-21', '2019-03-31', '30')",
|
||||
"Truncate table UnitsSold",
|
||||
"insert into UnitsSold (product_id, purchase_date, units) values ('1', '2019-02-25', '100')",
|
||||
"insert into UnitsSold (product_id, purchase_date, units) values ('1', '2019-03-01', '15')",
|
||||
"insert into UnitsSold (product_id, purchase_date, units) values ('2', '2019-02-10', '200')",
|
||||
"insert into UnitsSold (product_id, purchase_date, units) values ('2', '2019-03-22', '30')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
103
leetcode/originData/average-time-of-process-per-machine.json
Normal file
103
leetcode/originData/average-time-of-process-per-machine.json
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1801",
|
||||
"questionFrontendId": "1661",
|
||||
"boundTopicId": null,
|
||||
"title": "Average Time of Process per Machine",
|
||||
"titleSlug": "average-time-of-process-per-machine",
|
||||
"content": "<p>Table: <code>Activity</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| machine_id | int |\n| process_id | int |\n| activity_type | enum |\n| timestamp | float |\n+----------------+---------+\nThe table shows the user activities for a factory website.\n(machine_id, process_id, activity_type) is the primary key (combination of columns with unique values) of this table.\nmachine_id is the ID of a machine.\nprocess_id is the ID of a process running on the machine with ID machine_id.\nactivity_type is an ENUM (category) of type ('start', 'end').\ntimestamp is a float representing the current time in seconds.\n'start' means the machine starts the process at the given timestamp and 'end' means the machine ends the process at the given timestamp.\nThe 'start' timestamp will always be before the 'end' timestamp for every (machine_id, process_id) pair.</pre>\n\n<p> </p>\n\n<p>There is a factory website that has several machines each running the <strong>same number of processes</strong>. Write a solution to find the <strong>average time</strong> each machine takes to complete a process.</p>\n\n<p>The time to complete a process is the <code>'end' timestamp</code> minus the <code>'start' timestamp</code>. The average time is calculated by the total time to complete every process on the machine divided by the number of processes that were run.</p>\n\n<p>The resulting table should have the <code>machine_id</code> along with the <strong>average time</strong> as <code>processing_time</code>, which should be <strong>rounded to 3 decimal places</strong>.</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> \nActivity table:\n+------------+------------+---------------+-----------+\n| machine_id | process_id | activity_type | timestamp |\n+------------+------------+---------------+-----------+\n| 0 | 0 | start | 0.712 |\n| 0 | 0 | end | 1.520 |\n| 0 | 1 | start | 3.140 |\n| 0 | 1 | end | 4.120 |\n| 1 | 0 | start | 0.550 |\n| 1 | 0 | end | 1.550 |\n| 1 | 1 | start | 0.430 |\n| 1 | 1 | end | 1.420 |\n| 2 | 0 | start | 4.100 |\n| 2 | 0 | end | 4.512 |\n| 2 | 1 | start | 2.500 |\n| 2 | 1 | end | 5.000 |\n+------------+------------+---------------+-----------+\n<strong>Output:</strong> \n+------------+-----------------+\n| machine_id | processing_time |\n+------------+-----------------+\n| 0 | 0.894 |\n| 1 | 0.995 |\n| 2 | 1.456 |\n+------------+-----------------+\n<strong>Explanation:</strong> \nThere are 3 machines running 2 processes each.\nMachine 0's average time is ((1.520 - 0.712) + (4.120 - 3.140)) / 2 = 0.894\nMachine 1's average time is ((1.550 - 0.550) + (1.420 - 0.430)) / 2 = 0.995\nMachine 2's average time is ((4.512 - 4.100) + (5.000 - 2.500)) / 2 = 1.456\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 917,
|
||||
"dislikes": 79,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Activity\":[\"machine_id\",\"process_id\",\"activity_type\",\"timestamp\"]},\"rows\":{\"Activity\":[[0,0,\"start\",0.712],[0,0,\"end\",1.52],[0,1,\"start\",3.14],[0,1,\"end\",4.12],[1,0,\"start\",0.55],[1,0,\"end\",1.55],[1,1,\"start\",0.43],[1,1,\"end\",1.42],[2,0,\"start\",4.1],[2,0,\"end\",4.512],[2,1,\"start\",2.5],[2,1,\"end\",5]]}}",
|
||||
"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 get_average_time(activity: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"121.6K\", \"totalSubmission\": \"182K\", \"totalAcceptedRaw\": 121601, \"totalSubmissionRaw\": 181955, \"acRate\": \"66.8%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2091",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Activity\":[\"machine_id\",\"process_id\",\"activity_type\",\"timestamp\"]},\"rows\":{\"Activity\":[[0,0,\"start\",0.712],[0,0,\"end\",1.52],[0,1,\"start\",3.14],[0,1,\"end\",4.12],[1,0,\"start\",0.55],[1,0,\"end\",1.55],[1,1,\"start\",0.43],[1,1,\"end\",1.42],[2,0,\"start\",4.1],[2,0,\"end\",4.512],[2,1,\"start\",2.5],[2,1,\"end\",5]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Activity (machine_id int, process_id int, activity_type ENUM('start', 'end'), timestamp float)\"], \"mssql\": [\"create table Activity (machine_id int, process_id int, activity_type varchar(15) not null check(activity_type in ('start', 'end')), timestamp float)\"], \"oraclesql\": [\"create table Activity (machine_id int, process_id int, activity_type varchar(15) not null check(activity_type in ('start', 'end')), timestamp float)\"], \"database\": true, \"name\": \"get_average_time\", \"pythondata\": [\"Activity = pd.DataFrame([], columns=['machine_id', 'process_id', 'activity_type', 'timestamp']).astype({'machine_id':'Int64', 'process_id':'Int64', 'activity_type':'object', 'timestamp':'Float64'})\"], \"postgresql\": [\"Create table If Not Exists Activity (machine_id int, process_id int, activity_type VARCHAR(30) CHECK (activity_type IN ('start', 'end')), timestamp float)\\n\"], \"database_schema\": {\"Activity\": {\"machine_id\": \"INT\", \"process_id\": \"INT\", \"activity_type\": \"ENUM('start', 'end')\", \"timestamp\": \"FLOAT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Activity (machine_id int, process_id int, activity_type ENUM('start', 'end'), timestamp float)",
|
||||
"Truncate table Activity",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '0', 'start', '0.712')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '0', 'end', '1.52')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '1', 'start', '3.14')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '1', 'end', '4.12')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '0', 'start', '0.55')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '0', 'end', '1.55')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '1', 'start', '0.43')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '1', 'end', '1.42')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '0', 'start', '4.1')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '0', 'end', '4.512')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '1', 'start', '2.5')",
|
||||
"insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '1', 'end', '5')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
97
leetcode/originData/confirmation-rate.json
Normal file
97
leetcode/originData/confirmation-rate.json
Normal file
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2087",
|
||||
"questionFrontendId": "1934",
|
||||
"boundTopicId": null,
|
||||
"title": "Confirmation Rate",
|
||||
"titleSlug": "confirmation-rate",
|
||||
"content": "<p>Table: <code>Signups</code></p>\n\n<pre>\n+----------------+----------+\n| Column Name | Type |\n+----------------+----------+\n| user_id | int |\n| time_stamp | datetime |\n+----------------+----------+\nuser_id is the column of unique values for this table.\nEach row contains information about the signup time for the user with ID user_id.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Confirmations</code></p>\n\n<pre>\n+----------------+----------+\n| Column Name | Type |\n+----------------+----------+\n| user_id | int |\n| time_stamp | datetime |\n| action | ENUM |\n+----------------+----------+\n(user_id, time_stamp) is the primary key (combination of columns with unique values) for this table.\nuser_id is a foreign key (reference column) to the Signups table.\naction is an ENUM (category) of the type ('confirmed', 'timeout')\nEach row of this table indicates that the user with ID user_id requested a confirmation message at time_stamp and that confirmation message was either confirmed ('confirmed') or expired without confirming ('timeout').\n</pre>\n\n<p> </p>\n\n<p>The <strong>confirmation rate</strong> of a user is the number of <code>'confirmed'</code> messages divided by the total number of requested confirmation messages. The confirmation rate of a user that did not request any confirmation messages is <code>0</code>. Round the confirmation rate to <strong>two decimal</strong> places.</p>\n\n<p>Write a solution to find the <strong>confirmation rate</strong> of each user.</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> \nSignups table:\n+---------+---------------------+\n| user_id | time_stamp |\n+---------+---------------------+\n| 3 | 2020-03-21 10:16:13 |\n| 7 | 2020-01-04 13:57:59 |\n| 2 | 2020-07-29 23:09:44 |\n| 6 | 2020-12-09 10:39:37 |\n+---------+---------------------+\nConfirmations table:\n+---------+---------------------+-----------+\n| user_id | time_stamp | action |\n+---------+---------------------+-----------+\n| 3 | 2021-01-06 03:30:46 | timeout |\n| 3 | 2021-07-14 14:00:00 | timeout |\n| 7 | 2021-06-12 11:57:29 | confirmed |\n| 7 | 2021-06-13 12:58:28 | confirmed |\n| 7 | 2021-06-14 13:59:27 | confirmed |\n| 2 | 2021-01-22 00:00:00 | confirmed |\n| 2 | 2021-02-28 23:59:59 | timeout |\n+---------+---------------------+-----------+\n<strong>Output:</strong> \n+---------+-------------------+\n| user_id | confirmation_rate |\n+---------+-------------------+\n| 6 | 0.00 |\n| 3 | 0.00 |\n| 7 | 1.00 |\n| 2 | 0.50 |\n+---------+-------------------+\n<strong>Explanation:</strong> \nUser 6 did not request any confirmation messages. The confirmation rate is 0.\nUser 3 made 2 requests and both timed out. The confirmation rate is 0.\nUser 7 made 3 requests and all were confirmed. The confirmation rate is 1.\nUser 2 made 2 requests where one was confirmed and the other timed out. The confirmation rate is 1 / 2 = 0.5.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 588,
|
||||
"dislikes": 41,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\": {\"Signups\": [\"user_id\", \"time_stamp\"], \"Confirmations\": [\"user_id\", \"time_stamp\", \"action\"]}, \"rows\": {\"Signups\": [[3, \"2020-03-21 10:16:13\"], [7, \"2020-01-04 13:57:59\"], [2, \"2020-07-29 23:09:44\"], [6, \"2020-12-09 10:39:37\"]], \"Confirmations\": [[3, \"2021-01-06 03:30:46\", \"timeout\"], [3, \"2021-07-14 14:00:00\", \"timeout\"], [7, \"2021-06-12 11:57:29\", \"confirmed\"], [7, \"2021-06-13 12:58:28\", \"confirmed\"], [7, \"2021-06-14 13:59:27\", \"confirmed\"], [2, \"2021-01-22 00:00:00\", \"confirmed\"], [2, \"2021-02-28 23:59:59\", \"timeout\"]]}}",
|
||||
"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 confirmation_rate(signups: pd.DataFrame, confirmations: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"84.6K\", \"totalSubmission\": \"151K\", \"totalAcceptedRaw\": 84635, \"totalSubmissionRaw\": 151003, \"acRate\": \"56.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\": {\"Signups\": [\"user_id\", \"time_stamp\"], \"Confirmations\": [\"user_id\", \"time_stamp\", \"action\"]}, \"rows\": {\"Signups\": [[3, \"2020-03-21 10:16:13\"], [7, \"2020-01-04 13:57:59\"], [2, \"2020-07-29 23:09:44\"], [6, \"2020-12-09 10:39:37\"]], \"Confirmations\": [[3, \"2021-01-06 03:30:46\", \"timeout\"], [3, \"2021-07-14 14:00:00\", \"timeout\"], [7, \"2021-06-12 11:57:29\", \"confirmed\"], [7, \"2021-06-13 12:58:28\", \"confirmed\"], [7, \"2021-06-14 13:59:27\", \"confirmed\"], [2, \"2021-01-22 00:00:00\", \"confirmed\"], [2, \"2021-02-28 23:59:59\", \"timeout\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Signups (user_id int, time_stamp datetime)\", \"Create table If Not Exists Confirmations (user_id int, time_stamp datetime, action ENUM('confirmed','timeout'))\"], \"mssql\": [\"Create table Signups (user_id int, time_stamp datetime)\", \"Create table Confirmations (user_id int, time_stamp datetime, action VARCHAR(10) NOT NULL CHECK (action IN ('confirmed','timeout')))\"], \"oraclesql\": [\"Create table Signups (user_id int, time_stamp date)\", \"Create table Confirmations (user_id int, time_stamp date, action VARCHAR(10) NOT NULL CHECK (action IN ('confirmed','timeout')))\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD HH24:MI:SS'\"], \"database\": true, \"name\": \"confirmation_rate\", \"pythondata\": [\"Signups = pd.DataFrame([], columns=['user_id', 'time_stamp']).astype({'user_id':'Int64', 'time_stamp':'datetime64[ns]'})\", \"Confirmations = pd.DataFrame([], columns=['user_id', 'time_stamp', 'action']).astype({'user_id':'Int64', 'time_stamp':'datetime64[ns]', 'action':'object'})\"], \"postgresql\": [\"Create table If Not Exists Signups (user_id int, time_stamp timestamp)\\n\", \"Create table If Not Exists Confirmations (user_id int, time_stamp timestamp, action VARCHAR(30) CHECK (action IN ('confirmed','timeout')))\\n\"], \"database_schema\": {\"Signups\": {\"user_id\": \"INT\", \"time_stamp\": \"DATETIME\"}, \"Confirmations\": {\"user_id\": \"INT\", \"time_stamp\": \"DATETIME\", \"action\": \"ENUM('confirmed', 'timeout')\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Signups (user_id int, time_stamp datetime)",
|
||||
"Create table If Not Exists Confirmations (user_id int, time_stamp datetime, action ENUM('confirmed','timeout'))",
|
||||
"Truncate table Signups",
|
||||
"insert into Signups (user_id, time_stamp) values ('3', '2020-03-21 10:16:13')",
|
||||
"insert into Signups (user_id, time_stamp) values ('7', '2020-01-04 13:57:59')",
|
||||
"insert into Signups (user_id, time_stamp) values ('2', '2020-07-29 23:09:44')",
|
||||
"insert into Signups (user_id, time_stamp) values ('6', '2020-12-09 10:39:37')",
|
||||
"Truncate table Confirmations",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-01-06 03:30:46', 'timeout')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-07-14 14:00:00', 'timeout')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-12 11:57:29', 'confirmed')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-13 12:58:28', 'confirmed')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-14 13:59:27', 'confirmed')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-01-22 00:00:00', 'confirmed')",
|
||||
"insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-02-28 23:59:59', 'timeout')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
95
leetcode/originData/count-salary-categories.json
Normal file
95
leetcode/originData/count-salary-categories.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2057",
|
||||
"questionFrontendId": "1907",
|
||||
"boundTopicId": null,
|
||||
"title": "Count Salary Categories",
|
||||
"titleSlug": "count-salary-categories",
|
||||
"content": "<p>Table: <code>Accounts</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| account_id | int |\n| income | int |\n+-------------+------+\naccount_id is the primary key (column with unique values) for this table.\nEach row contains information about the monthly income for one bank account.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to calculate the number of bank accounts for each salary category. The salary categories are:</p>\n\n<ul>\n\t<li><code>"Low Salary"</code>: All the salaries <strong>strictly less</strong> than <code>$20000</code>.</li>\n\t<li><code>"Average Salary"</code>: All the salaries in the <strong>inclusive</strong> range <code>[$20000, $50000]</code>.</li>\n\t<li><code>"High Salary"</code>: All the salaries <strong>strictly greater</strong> than <code>$50000</code>.</li>\n</ul>\n\n<p>The result table <strong>must</strong> contain all three categories. If there are no accounts in a category, return <code>0</code>.</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> \nAccounts table:\n+------------+--------+\n| account_id | income |\n+------------+--------+\n| 3 | 108939 |\n| 2 | 12747 |\n| 8 | 87709 |\n| 6 | 91796 |\n+------------+--------+\n<strong>Output:</strong> \n+----------------+----------------+\n| category | accounts_count |\n+----------------+----------------+\n| Low Salary | 1 |\n| Average Salary | 0 |\n| High Salary | 3 |\n+----------------+----------------+\n<strong>Explanation:</strong> \nLow Salary: Account 2.\nAverage Salary: No accounts.\nHigh Salary: Accounts 3, 6, and 8.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 311,
|
||||
"dislikes": 61,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Create a Session Bar Chart\", \"titleSlug\": \"create-a-session-bar-chart\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Accounts\":[\"account_id\",\"income\"]},\"rows\":{\"Accounts\":[[3,108939],[2,12747],[8,87709],[6,91796]]}}",
|
||||
"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 count_salary_categories(accounts: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"47.8K\", \"totalSubmission\": \"82.7K\", \"totalAcceptedRaw\": 47831, \"totalSubmissionRaw\": 82718, \"acRate\": \"57.8%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2021",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Accounts\":[\"account_id\",\"income\"]},\"rows\":{\"Accounts\":[[3,108939],[2,12747],[8,87709],[6,91796]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Accounts (account_id int, income int)\"], \"mssql\": [\"Create table Accounts (account_id int, income int)\"], \"oraclesql\": [\"Create table Accounts (account_id int, income int)\"], \"database\": true, \"name\": \"count_salary_categories\", \"pythondata\": [\"Accounts = pd.DataFrame([], columns=['account_id', 'income']).astype({'account_id':'Int64', 'income':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Accounts (account_id int, income int)\"], \"database_schema\": {\"Accounts\": {\"account_id\": \"INT\", \"income\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Accounts (account_id int, income int)",
|
||||
"Truncate table Accounts",
|
||||
"insert into Accounts (account_id, income) values ('3', '108939')",
|
||||
"insert into Accounts (account_id, income) values ('2', '12747')",
|
||||
"insert into Accounts (account_id, income) values ('8', '87709')",
|
||||
"insert into Accounts (account_id, income) values ('6', '91796')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
100
leetcode/originData/customers-who-bought-all-products.json
Normal file
100
leetcode/originData/customers-who-bought-all-products.json
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"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": 590,
|
||||
"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.7K\", \"totalAcceptedRaw\": 105271, \"totalSubmissionRaw\": 171696, \"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"
|
||||
}
|
||||
}
|
||||
}
|
102
leetcode/originData/employee-bonus.json
Normal file
102
leetcode/originData/employee-bonus.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "577",
|
||||
"questionFrontendId": "577",
|
||||
"boundTopicId": null,
|
||||
"title": "Employee Bonus",
|
||||
"titleSlug": "employee-bonus",
|
||||
"content": "<p>Table: <code>Employee</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| empId | int |\n| name | varchar |\n| supervisor | int |\n| salary | int |\n+-------------+---------+\nempId is the column with unique values for this table.\nEach row of this table indicates the name and the ID of an employee in addition to their salary and the id of their manager.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Bonus</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| empId | int |\n| bonus | int |\n+-------------+------+\nempId is the column of unique values for this table.\nempId is a foreign key (reference column) to empId from the Employee table.\nEach row of this table contains the id of an employee and their respective bonus.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to report the name and bonus amount of each employee with a bonus <strong>less than</strong> <code>1000</code>.</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> \nEmployee table:\n+-------+--------+------------+--------+\n| empId | name | supervisor | salary |\n+-------+--------+------------+--------+\n| 3 | Brad | null | 4000 |\n| 1 | John | 3 | 1000 |\n| 2 | Dan | 3 | 2000 |\n| 4 | Thomas | 3 | 4000 |\n+-------+--------+------------+--------+\nBonus table:\n+-------+-------+\n| empId | bonus |\n+-------+-------+\n| 2 | 500 |\n| 4 | 2000 |\n+-------+-------+\n<strong>Output:</strong> \n+------+-------+\n| name | bonus |\n+------+-------+\n| Brad | null |\n| John | null |\n| Dan | 500 |\n+------+-------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 688,
|
||||
"dislikes": 178,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Combine Two Tables\", \"titleSlug\": \"combine-two-tables\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Employee\":[\"empId\",\"name\",\"supervisor\",\"salary\"],\"Bonus\":[\"empId\",\"bonus\"]},\"rows\":{\"Employee\":[[3,\"Brad\",null,4000],[1,\"John\",3,1000],[2,\"Dan\",3,2000],[4,\"Thomas\",3,4000]],\"Bonus\":[[2,500],[4,2000]]}}",
|
||||
"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 employee_bonus(employee: pd.DataFrame, bonus: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"214.5K\", \"totalSubmission\": \"290.8K\", \"totalAcceptedRaw\": 214505, \"totalSubmissionRaw\": 290845, \"acRate\": \"73.8%\"}",
|
||||
"hints": [
|
||||
"If the EmpId in table Employee has no match in table Bonus, we consider that the corresponding bonus is null and null is smaller than 1000.",
|
||||
"Inner join is the default join, we can solve the mismatching problem by using outer join."
|
||||
],
|
||||
"solution": {
|
||||
"id": "182",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Employee\":[\"empId\",\"name\",\"supervisor\",\"salary\"],\"Bonus\":[\"empId\",\"bonus\"]},\"rows\":{\"Employee\":[[3,\"Brad\",null,4000],[1,\"John\",3,1000],[2,\"Dan\",3,2000],[4,\"Thomas\",3,4000]],\"Bonus\":[[2,500],[4,2000]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int)\", \"Create table If Not Exists Bonus (empId int, bonus int)\"], \"mssql\": [\"Create table Employee (empId int, name varchar(255), supervisor int, salary int)\", \"Create table Bonus (empId int, bonus int)\"], \"oraclesql\": [\"Create table Employee (empId int, name varchar(255), supervisor int, salary int)\", \"Create table Bonus (empId int, bonus int)\"], \"database\": true, \"name\": \"employee_bonus\", \"manual\": false, \"pythondata\": [\"Employee = pd.DataFrame([], columns=['empId', 'name', 'supervisor', 'salary']).astype({'empId':'Int64', 'name':'object', 'supervisor':'Int64', 'salary':'Int64'})\", \"Bonus = pd.DataFrame([], columns=['empId', 'bonus']).astype({'empId':'Int64', 'bonus':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int)\\n\", \"Create table If Not Exists Bonus (empId int, bonus int)\"], \"database_schema\": {\"Employee\": {\"empId\": \"INT\", \"name\": \"VARCHAR(255)\", \"supervisor\": \"INT\", \"salary\": \"INT\"}, \"Bonus\": {\"empId\": \"INT\", \"bonus\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int)",
|
||||
"Create table If Not Exists Bonus (empId int, bonus int)",
|
||||
"Truncate table Employee",
|
||||
"insert into Employee (empId, name, supervisor, salary) values ('3', 'Brad', 'None', '4000')",
|
||||
"insert into Employee (empId, name, supervisor, salary) values ('1', 'John', '3', '1000')",
|
||||
"insert into Employee (empId, name, supervisor, salary) values ('2', 'Dan', '3', '2000')",
|
||||
"insert into Employee (empId, name, supervisor, salary) values ('4', 'Thomas', '3', '4000')",
|
||||
"Truncate table Bonus",
|
||||
"insert into Bonus (empId, bonus) values ('2', '500')",
|
||||
"insert into Bonus (empId, bonus) values ('4', '2000')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2127",
|
||||
"questionFrontendId": "1978",
|
||||
"boundTopicId": null,
|
||||
"title": "Employees Whose Manager Left the Company",
|
||||
"titleSlug": "employees-whose-manager-left-the-company",
|
||||
"content": "<p>Table: <code>Employees</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| employee_id | int |\n| name | varchar |\n| manager_id | int |\n| salary | int |\n+-------------+----------+\nIn SQL, employee_id is the primary key for this table.\nThis table contains information about the employees, their salary, and the ID of their manager. Some employees do not have a manager (manager_id is null). \n</pre>\n\n<p> </p>\n\n<p>Find the IDs of the employees whose salary is strictly less than <code>$30000</code> and whose manager left the company. When a manager leaves the company, their information is deleted from the <code>Employees</code> table, but the reports still have their <code>manager_id</code> set to the manager that left.</p>\n\n<p>Return the result table ordered by <code>employee_id</code>.</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> \nEmployees table:\n+-------------+-----------+------------+--------+\n| employee_id | name | manager_id | salary |\n+-------------+-----------+------------+--------+\n| 3 | Mila | 9 | 60301 |\n| 12 | Antonella | null | 31000 |\n| 13 | Emery | null | 67084 |\n| 1 | Kalel | 11 | 21241 |\n| 9 | Mikaela | null | 50937 |\n| 11 | Joziah | 6 | 28485 |\n+-------------+-----------+------------+--------+\n<strong>Output:</strong> \n+-------------+\n| employee_id |\n+-------------+\n| 11 |\n+-------------+\n\n<strong>Explanation:</strong> \nThe employees with a salary less than $30000 are 1 (Kalel) and 11 (Joziah).\nKalel's manager is employee 11, who is still in the company (Joziah).\nJoziah's manager is employee 6, who left the company because there is no row for employee 6 as it was deleted.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 271,
|
||||
"dislikes": 22,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\": {\"Employees\": [\"employee_id\", \"name\", \"manager_id\", \"salary\"]}, \"rows\": {\"Employees\": [[3, \"Mila\", 9, 60301], [12, \"Antonella\", null, 31000], [13, \"Emery\", null, 67084], [1, \"Kalel\", 11, 21241], [9, \"Mikaela\", null, 50937], [11, \"Joziah\", 6, 28485]]}}",
|
||||
"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_employees(employees: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"52.6K\", \"totalSubmission\": \"111.9K\", \"totalAcceptedRaw\": 52557, \"totalSubmissionRaw\": 111928, \"acRate\": \"47.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\": {\"Employees\": [\"employee_id\", \"name\", \"manager_id\", \"salary\"]}, \"rows\": {\"Employees\": [[3, \"Mila\", 9, 60301], [12, \"Antonella\", null, 31000], [13, \"Emery\", null, 67084], [1, \"Kalel\", 11, 21241], [9, \"Mikaela\", null, 50937], [11, \"Joziah\", 6, 28485]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employees (employee_id int, name varchar(20), manager_id int, salary int)\"], \"mssql\": [\"Create table Employees (employee_id int, name varchar(20), manager_id int, salary int)\"], \"oraclesql\": [\"Create table Employees (employee_id int, name varchar(20), manager_id int, salary int)\"], \"database\": true, \"name\": \"find_employees\", \"pythondata\": [\"Employees = pd.DataFrame([], columns=['employee_id', 'name', 'manager_id', 'salary']).astype({'employee_id':'Int64', 'name':'object', 'manager_id':'Int64', 'salary':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Employees (employee_id int, name varchar(20), manager_id int, salary int)\"], \"database_schema\": {\"Employees\": {\"employee_id\": \"INT\", \"name\": \"VARCHAR(20)\", \"manager_id\": \"INT\", \"salary\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employees (employee_id int, name varchar(20), manager_id int, salary int)",
|
||||
"Truncate table Employees",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('3', 'Mila', '9', '60301')",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('12', 'Antonella', 'None', '31000')",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('13', 'Emery', 'None', '67084')",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('1', 'Kalel', '11', '21241')",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('9', 'Mikaela', 'None', '50937')",
|
||||
"insert into Employees (employee_id, name, manager_id, salary) values ('11', 'Joziah', '6', '28485')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
98
leetcode/originData/find-users-with-valid-e-mails.json
Normal file
98
leetcode/originData/find-users-with-valid-e-mails.json
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1664",
|
||||
"questionFrontendId": "1517",
|
||||
"boundTopicId": null,
|
||||
"title": "Find Users With Valid E-Mails",
|
||||
"titleSlug": "find-users-with-valid-e-mails",
|
||||
"content": "<p>Table: <code>Users</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| user_id | int |\n| name | varchar |\n| mail | varchar |\n+---------------+---------+\nuser_id is the primary key (column with unique values) for this table.\nThis table contains information of the users signed up in a website. Some e-mails are invalid.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the users who have <strong>valid emails</strong>.</p>\n\n<p>A valid e-mail has a prefix name and a domain where:</p>\n\n<ul>\n\t<li><strong>The prefix name</strong> is a string that may contain letters (upper or lower case), digits, underscore <code>'_'</code>, period <code>'.'</code>, and/or dash <code>'-'</code>. The prefix name <strong>must</strong> start with a letter.</li>\n\t<li><strong>The domain</strong> is <code>'@leetcode.com'</code>.</li>\n</ul>\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> \nUsers table:\n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 2 | Jonathan | jonathanisgreat |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n| 5 | Marwan | quarz#2020@leetcode.com |\n| 6 | David | david69@gmail.com |\n| 7 | Shapiro | .shapo@leetcode.com |\n+---------+-----------+-------------------------+\n<strong>Output:</strong> \n+---------+-----------+-------------------------+\n| user_id | name | mail |\n+---------+-----------+-------------------------+\n| 1 | Winston | winston@leetcode.com |\n| 3 | Annabelle | bella-@leetcode.com |\n| 4 | Sally | sally.come@leetcode.com |\n+---------+-----------+-------------------------+\n<strong>Explanation:</strong> \nThe mail of user 2 does not have a domain.\nThe mail of user 5 has the # sign which is not allowed.\nThe mail of user 6 does not have the leetcode domain.\nThe mail of user 7 starts with a period.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 352,
|
||||
"dislikes": 219,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Users\":[\"user_id\",\"name\",\"mail\"]},\"rows\":{\"Users\":[[1,\"Winston\",\"winston@leetcode.com\"],[2,\"Jonathan\",\"jonathanisgreat\"],[3,\"Annabelle\",\"bella-@leetcode.com\"],[4,\"Sally\",\"sally.come@leetcode.com\"],[5,\"Marwan\",\"quarz#2020@leetcode.com\"],[6,\"David\",\"david69@gmail.com\"],[7,\"Shapiro\",\".shapo@leetcode.com\"]]}}",
|
||||
"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 valid_emails(users: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"66.2K\", \"totalSubmission\": \"140.9K\", \"totalAcceptedRaw\": 66211, \"totalSubmissionRaw\": 140892, \"acRate\": \"47.0%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2011",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Users\":[\"user_id\",\"name\",\"mail\"]},\"rows\":{\"Users\":[[1,\"Winston\",\"winston@leetcode.com\"],[2,\"Jonathan\",\"jonathanisgreat\"],[3,\"Annabelle\",\"bella-@leetcode.com\"],[4,\"Sally\",\"sally.come@leetcode.com\"],[5,\"Marwan\",\"quarz#2020@leetcode.com\"],[6,\"David\",\"david69@gmail.com\"],[7,\"Shapiro\",\".shapo@leetcode.com\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))\"], \"mssql\": [\"Create table Users (user_id int, name varchar(30), mail varchar(50))\"], \"oraclesql\": [\"Create table Users (user_id int, name varchar(30), mail varchar(50))\"], \"database\": true, \"name\": \"valid_emails\", \"pythondata\": [\"Users = pd.DataFrame([], columns=['user_id', 'name', 'mail']).astype({'user_id':'int64', 'name':'object', 'mail':'object'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))\"], \"database_schema\": {\"Users\": {\"user_id\": \"INT\", \"name\": \"VARCHAR(30)\", \"mail\": \"VARCHAR(50)\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))",
|
||||
"Truncate table Users",
|
||||
"insert into Users (user_id, name, mail) values ('1', 'Winston', 'winston@leetcode.com')",
|
||||
"insert into Users (user_id, name, mail) values ('2', 'Jonathan', 'jonathanisgreat')",
|
||||
"insert into Users (user_id, name, mail) values ('3', 'Annabelle', 'bella-@leetcode.com')",
|
||||
"insert into Users (user_id, name, mail) values ('4', 'Sally', 'sally.come@leetcode.com')",
|
||||
"insert into Users (user_id, name, mail) values ('5', 'Marwan', 'quarz#2020@leetcode.com')",
|
||||
"insert into Users (user_id, name, mail) values ('6', 'David', 'david69@gmail.com')",
|
||||
"insert into Users (user_id, name, mail) values ('7', 'Shapiro', '.shapo@leetcode.com')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "602",
|
||||
"questionFrontendId": "602",
|
||||
"boundTopicId": null,
|
||||
"title": "Friend Requests II: Who Has the Most Friends",
|
||||
"titleSlug": "friend-requests-ii-who-has-the-most-friends",
|
||||
"content": "<p>Table: <code>RequestAccepted</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| requester_id | int |\n| accepter_id | int |\n| accept_date | date |\n+----------------+---------+\n(requester_id, accepter_id) is the primary key (combination of columns with unique values) for this table.\nThis table contains the ID of the user who sent the request, the ID of the user who received the request, and the date when the request was accepted.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the people who have the most friends and the most friends number.</p>\n\n<p>The test cases are generated so that only one person has the most friends.</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> \nRequestAccepted table:\n+--------------+-------------+-------------+\n| requester_id | accepter_id | accept_date |\n+--------------+-------------+-------------+\n| 1 | 2 | 2016/06/03 |\n| 1 | 3 | 2016/06/08 |\n| 2 | 3 | 2016/06/08 |\n| 3 | 4 | 2016/06/09 |\n+--------------+-------------+-------------+\n<strong>Output:</strong> \n+----+-----+\n| id | num |\n+----+-----+\n| 3 | 3 |\n+----+-----+\n<strong>Explanation:</strong> \nThe person with id 3 is a friend of people 1, 2, and 4, so he has three friends in total, which is the most number than any others.\n</pre>\n\n<p> </p>\n<p><strong>Follow up:</strong> In the real world, multiple people could have the same most number of friends. Could you find all these people in this case?</p>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 537,
|
||||
"dislikes": 96,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"RequestAccepted\":[\"requester_id\",\"accepter_id\",\"accept_date\"]},\"rows\":{\"RequestAccepted\":[[1,2,\"2016/06/03\"],[1,3,\"2016/06/08\"],[2,3,\"2016/06/08\"],[3,4,\"2016/06/09\"]]}}",
|
||||
"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 most_friends(request_accepted: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"91.7K\", \"totalSubmission\": \"161.3K\", \"totalAcceptedRaw\": 91690, \"totalSubmissionRaw\": 161334, \"acRate\": \"56.8%\"}",
|
||||
"hints": [
|
||||
"Being friends is bidirectional. If you accept someone's adding friend request, both you and the other person will have one more friend."
|
||||
],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"RequestAccepted\":[\"requester_id\",\"accepter_id\",\"accept_date\"]},\"rows\":{\"RequestAccepted\":[[1,2,\"2016/06/03\"],[1,3,\"2016/06/08\"],[2,3,\"2016/06/08\"],[3,4,\"2016/06/09\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"], \"mssql\": [\"Create table RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"], \"oraclesql\": [\"Create table RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\", \"Alter SESSION set NLS_DATE_FORMAT = 'YYYY/MM/DD'\"], \"database\": true, \"name\": \"most_friends\", \"pythondata\": [\"RequestAccepted = pd.DataFrame([], columns=['requester_id', 'accepter_id', 'accept_date']).astype({'requester_id':'Int64', 'accepter_id':'Int64', 'accept_date':'datetime64[ns]'})\"], \"postgresql\": [\"\\nCreate table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"], \"database_schema\": {\"RequestAccepted\": {\"requester_id\": \"INT\", \"accepter_id\": \"INT\", \"accept_date\": \"DATE\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)",
|
||||
"Truncate table RequestAccepted",
|
||||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03')",
|
||||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08')",
|
||||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08')",
|
||||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
96
leetcode/originData/game-play-analysis-iv.json
Normal file
96
leetcode/originData/game-play-analysis-iv.json
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1182",
|
||||
"questionFrontendId": "550",
|
||||
"boundTopicId": null,
|
||||
"title": "Game Play Analysis IV",
|
||||
"titleSlug": "game-play-analysis-iv",
|
||||
"content": "<p>Table: <code>Activity</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| player_id | int |\n| device_id | int |\n| event_date | date |\n| games_played | int |\n+--------------+---------+\n(player_id, event_date) is the primary key (combination of columns with unique values) of this table.\nThis table shows the activity of players of some games.\nEach row is a record of a player who logged in and played a number of games (possibly 0) before logging out on someday using some device.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to report the <strong>fraction</strong> of players that logged in again on the day after the day they first logged in, <strong>rounded to 2 decimal places</strong>. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.</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> \nActivity table:\n+-----------+-----------+------------+--------------+\n| player_id | device_id | event_date | games_played |\n+-----------+-----------+------------+--------------+\n| 1 | 2 | 2016-03-01 | 5 |\n| 1 | 2 | 2016-03-02 | 6 |\n| 2 | 3 | 2017-06-25 | 1 |\n| 3 | 1 | 2016-03-02 | 0 |\n| 3 | 4 | 2018-07-03 | 5 |\n+-----------+-----------+------------+--------------+\n<strong>Output:</strong> \n+-----------+\n| fraction |\n+-----------+\n| 0.33 |\n+-----------+\n<strong>Explanation:</strong> \nOnly the player with id 1 logged back in after the first day he had logged in so the answer is 1/3 = 0.33\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 709,
|
||||
"dislikes": 148,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Game Play Analysis III\", \"titleSlug\": \"game-play-analysis-iii\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Game Play Analysis V\", \"titleSlug\": \"game-play-analysis-v\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Activity\":[\"player_id\",\"device_id\",\"event_date\",\"games_played\"]},\"rows\":{\"Activity\":[[1,2,\"2016-03-01\",5],[1,2,\"2016-03-02\",6],[2,3,\"2017-06-25\",1],[3,1,\"2016-03-02\",0],[3,4,\"2018-07-03\",5]]}}",
|
||||
"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 gameplay_analysis(activity: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"104.8K\", \"totalSubmission\": \"293.9K\", \"totalAcceptedRaw\": 104764, \"totalSubmissionRaw\": 293884, \"acRate\": \"35.6%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "1602",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Activity\":[\"player_id\",\"device_id\",\"event_date\",\"games_played\"]},\"rows\":{\"Activity\":[[1,2,\"2016-03-01\",5],[1,2,\"2016-03-02\",6],[2,3,\"2017-06-25\",1],[3,1,\"2016-03-02\",0],[3,4,\"2018-07-03\",5]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)\"], \"mssql\": [\"Create table Activity (player_id int, device_id int, event_date date, games_played int)\"], \"oraclesql\": [\"Create table Activity (player_id int, device_id int, event_date date, games_played int)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"gameplay_analysis\", \"pythondata\": [\"Activity = pd.DataFrame([], columns=['player_id', 'device_id', 'event_date', 'games_played']).astype({'player_id':'Int64', 'device_id':'Int64', 'event_date':'datetime64[ns]', 'games_played':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)\"], \"database_schema\": {\"Activity\": {\"player_id\": \"INT\", \"device_id\": \"INT\", \"event_date\": \"DATE\", \"games_played\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)",
|
||||
"Truncate table Activity",
|
||||
"insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')",
|
||||
"insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-02', '6')",
|
||||
"insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1')",
|
||||
"insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0')",
|
||||
"insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
91
leetcode/originData/immediate-food-delivery-ii.json
Normal file
91
leetcode/originData/immediate-food-delivery-ii.json
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1292",
|
||||
"questionFrontendId": "1174",
|
||||
"boundTopicId": null,
|
||||
"title": "Immediate Food Delivery II",
|
||||
"titleSlug": "immediate-food-delivery-ii",
|
||||
"content": "<p>Table: <code>Delivery</code></p>\n\n<pre>\n+-----------------------------+---------+\n| Column Name | Type |\n+-----------------------------+---------+\n| delivery_id | int |\n| customer_id | int |\n| order_date | date |\n| customer_pref_delivery_date | date |\n+-----------------------------+---------+\ndelivery_id is the column of unique values of this table.\nThe table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).\n</pre>\n\n<p> </p>\n\n<p>If the customer's preferred delivery date is the same as the order date, then the order is called <strong>immediate;</strong> otherwise, it is called <strong>scheduled</strong>.</p>\n\n<p>The <strong>first order</strong> of a customer is the order with the earliest order date that the customer made. It is guaranteed that a customer has precisely one first order.</p>\n\n<p>Write a solution to find the percentage of immediate orders in the first orders of all customers, <strong>rounded to 2 decimal places</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> \nDelivery table:\n+-------------+-------------+------------+-----------------------------+\n| delivery_id | customer_id | order_date | customer_pref_delivery_date |\n+-------------+-------------+------------+-----------------------------+\n| 1 | 1 | 2019-08-01 | 2019-08-02 |\n| 2 | 2 | 2019-08-02 | 2019-08-02 |\n| 3 | 1 | 2019-08-11 | 2019-08-12 |\n| 4 | 3 | 2019-08-24 | 2019-08-24 |\n| 5 | 3 | 2019-08-21 | 2019-08-22 |\n| 6 | 2 | 2019-08-11 | 2019-08-13 |\n| 7 | 4 | 2019-08-09 | 2019-08-09 |\n+-------------+-------------+------------+-----------------------------+\n<strong>Output:</strong> \n+----------------------+\n| immediate_percentage |\n+----------------------+\n| 50.00 |\n+----------------------+\n<strong>Explanation:</strong> \nThe customer id 1 has a first order with delivery id 1 and it is scheduled.\nThe customer id 2 has a first order with delivery id 2 and it is immediate.\nThe customer id 3 has a first order with delivery id 5 and it is scheduled.\nThe customer id 4 has a first order with delivery id 7 and it is immediate.\nHence, half the customers have immediate first orders.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 523,
|
||||
"dislikes": 89,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Delivery\":[\"delivery_id\",\"customer_id\",\"order_date\",\"customer_pref_delivery_date\"]},\"rows\":{\"Delivery\":[[1,1,\"2019-08-01\",\"2019-08-02\"],[2,2,\"2019-08-02\",\"2019-08-02\"],[3,1,\"2019-08-11\",\"2019-08-12\"],[4,3,\"2019-08-24\",\"2019-08-24\"],[5,3,\"2019-08-21\",\"2019-08-22\"],[6,2,\"2019-08-11\",\"2019-08-13\"],[7,4,\"2019-08-09\",\"2019-08-09\"]]}}",
|
||||
"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 immediate_food_delivery(delivery: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"80.5K\", \"totalSubmission\": \"158.4K\", \"totalAcceptedRaw\": 80457, \"totalSubmissionRaw\": 158366, \"acRate\": \"50.8%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Delivery\":[\"delivery_id\",\"customer_id\",\"order_date\",\"customer_pref_delivery_date\"]},\"rows\":{\"Delivery\":[[1,1,\"2019-08-01\",\"2019-08-02\"],[2,2,\"2019-08-02\",\"2019-08-02\"],[3,1,\"2019-08-11\",\"2019-08-12\"],[4,3,\"2019-08-24\",\"2019-08-24\"],[5,3,\"2019-08-21\",\"2019-08-22\"],[6,2,\"2019-08-11\",\"2019-08-13\"],[7,4,\"2019-08-09\",\"2019-08-09\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date)\"], \"mssql\": [\"Create table Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date)\"], \"oraclesql\": [\"Create table Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"immediate_food_delivery\", \"pythondata\": [\"Delivery = pd.DataFrame([], columns=['delivery_id', 'customer_id', 'order_date', 'customer_pref_delivery_date']).astype({'delivery_id':'Int64', 'customer_id':'Int64', 'order_date':'datetime64[ns]', 'customer_pref_delivery_date':'datetime64[ns]'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date)\"], \"database_schema\": {\"Delivery\": {\"delivery_id\": \"INT\", \"customer_id\": \"INT\", \"order_date\": \"DATE\", \"customer_pref_delivery_date\": \"DATE\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date)",
|
||||
"Truncate table Delivery",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('1', '1', '2019-08-01', '2019-08-02')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('2', '2', '2019-08-02', '2019-08-02')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('3', '1', '2019-08-11', '2019-08-12')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('4', '3', '2019-08-24', '2019-08-24')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('5', '3', '2019-08-21', '2019-08-22')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('6', '2', '2019-08-11', '2019-08-13')",
|
||||
"insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('7', '4', '2019-08-09', '2019-08-09')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
93
leetcode/originData/invalid-tweets.json
Normal file
93
leetcode/originData/invalid-tweets.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1827",
|
||||
"questionFrontendId": "1683",
|
||||
"boundTopicId": null,
|
||||
"title": "Invalid Tweets",
|
||||
"titleSlug": "invalid-tweets",
|
||||
"content": "<p>Table: <code>Tweets</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| tweet_id | int |\n| content | varchar |\n+----------------+---------+\ntweet_id is the primary key (column with unique values) for this table.\nThis table contains all the tweets in a social media app.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the IDs of the invalid tweets. The tweet is invalid if the number of characters used in the content of the tweet is <strong>strictly greater</strong> than <code>15</code>.</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> \nTweets table:\n+----------+----------------------------------+\n| tweet_id | content |\n+----------+----------------------------------+\n| 1 | Vote for Biden |\n| 2 | Let us make America great again! |\n+----------+----------------------------------+\n<strong>Output:</strong> \n+----------+\n| tweet_id |\n+----------+\n| 2 |\n+----------+\n<strong>Explanation:</strong> \nTweet 1 has length = 14. It is a valid tweet.\nTweet 2 has length = 32. It is an invalid tweet.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 698,
|
||||
"dislikes": 228,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Tweets\":[\"tweet_id\",\"content\"]},\"rows\":{\"Tweets\":[[1,\"Vote for Biden\"],[2,\"Let us make America great again!\"]]}}",
|
||||
"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 invalid_tweets(tweets: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"236.5K\", \"totalSubmission\": \"279.6K\", \"totalAcceptedRaw\": 236486, \"totalSubmissionRaw\": 279634, \"acRate\": \"84.6%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "1940",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Tweets\":[\"tweet_id\",\"content\"]},\"rows\":{\"Tweets\":[[1,\"Vote for Biden\"],[2,\"Let us make America great again!\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Tweets(tweet_id int, content varchar(50))\"], \"mssql\": [\"Create table Tweets(tweet_id int, content varchar(50))\"], \"oraclesql\": [\"Create table Tweets(tweet_id int, content varchar(50))\"], \"database\": true, \"name\": \"invalid_tweets\", \"pythondata\": [\"Tweets = pd.DataFrame([], columns=['tweet_id', 'content']).astype({'tweet_id':'Int64', 'content':'object'})\"], \"postgresql\": [\"Create table If Not Exists Tweets(tweet_id int, content varchar(50))\"], \"database_schema\": {\"Tweets\": {\"tweet_id\": \"INT\", \"content\": \"VARCHAR(50)\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Tweets(tweet_id int, content varchar(50))",
|
||||
"Truncate table Tweets",
|
||||
"insert into Tweets (tweet_id, content) values ('1', 'Vote for Biden')",
|
||||
"insert into Tweets (tweet_id, content) values ('2', 'Let us make America great again!')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
97
leetcode/originData/investments-in-2016.json
Normal file
97
leetcode/originData/investments-in-2016.json
Normal file
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "585",
|
||||
"questionFrontendId": "585",
|
||||
"boundTopicId": null,
|
||||
"title": "Investments in 2016",
|
||||
"titleSlug": "investments-in-2016",
|
||||
"content": "<p>Table: <code>Insurance</code></p>\n\n<pre>\n+-------------+-------+\n| Column Name | Type |\n+-------------+-------+\n| pid | int |\n| tiv_2015 | float |\n| tiv_2016 | float |\n| lat | float |\n| lon | float |\n+-------------+-------+\npid is the primary key (column with unique values) for this table.\nEach row of this table contains information about one policy where:\npid is the policyholder's policy ID.\ntiv_2015 is the total investment value in 2015 and tiv_2016 is the total investment value in 2016.\nlat is the latitude of the policy holder's city. It's guaranteed that lat is not NULL.\nlon is the longitude of the policy holder's city. It's guaranteed that lon is not NULL.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to report the sum of all total investment values in 2016 <code>tiv_2016</code>, for all policyholders who:</p>\n\n<ul>\n\t<li>have the same <code>tiv_2015</code> value as one or more other policyholders, and</li>\n\t<li>are not located in the same city as any other policyholder (i.e., the (<code>lat, lon</code>) attribute pairs must be unique).</li>\n</ul>\n\n<p>Round <code>tiv_2016</code> to <strong>two decimal places</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> \nInsurance table:\n+-----+----------+----------+-----+-----+\n| pid | tiv_2015 | tiv_2016 | lat | lon |\n+-----+----------+----------+-----+-----+\n| 1 | 10 | 5 | 10 | 10 |\n| 2 | 20 | 20 | 20 | 20 |\n| 3 | 10 | 30 | 20 | 20 |\n| 4 | 10 | 40 | 40 | 40 |\n+-----+----------+----------+-----+-----+\n<strong>Output:</strong> \n+----------+\n| tiv_2016 |\n+----------+\n| 45.00 |\n+----------+\n<strong>Explanation:</strong> \nThe first record in the table, like the last record, meets both of the two criteria.\nThe tiv_2015 value 10 is the same as the third and fourth records, and its location is unique.\n\nThe second record does not meet any of the two criteria. Its tiv_2015 is not like any other policyholders and its location is the same as the third record, which makes the third record fail, too.\nSo, the result is the sum of tiv_2016 of the first and last record, which is 45.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 450,
|
||||
"dislikes": 398,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Insurance\":[\"pid\",\"tiv_2015\",\"tiv_2016\",\"lat\",\"lon\"]},\"rows\":{\"Insurance\":[[1,10,5,10,10],[2,20,20,20,20],[3,10,30,20,20],[4,10,40,40,40]]}}",
|
||||
"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_investments(insurance: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"72.4K\", \"totalSubmission\": \"153.7K\", \"totalAcceptedRaw\": 72438, \"totalSubmissionRaw\": 153695, \"acRate\": \"47.1%\"}",
|
||||
"hints": [
|
||||
"Make the (LAT, LON) a pair to represent the location information"
|
||||
],
|
||||
"solution": {
|
||||
"id": "130",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Insurance\":[\"pid\",\"tiv_2015\",\"tiv_2016\",\"lat\",\"lon\"]},\"rows\":{\"Insurance\":[[1,10,5,10,10],[2,20,20,20,20],[3,10,30,20,20],[4,10,40,40,40]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"], \"mssql\": [\"Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"], \"oraclesql\": [\"Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"], \"database\": true, \"name\": \"find_investments\", \"pythondata\": [\"Insurance = pd.DataFrame([], columns=['pid', 'tiv_2015', 'tiv_2016', 'lat', 'lon']).astype({'pid':'Int64', 'tiv_2015':'Float64', 'tiv_2016':'Float64', 'lat':'Float64', 'lon':'Float64'})\"], \"postgresql\": [\"\\nCreate Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"], \"database_schema\": {\"Insurance\": {\"pid\": \"INT\", \"tiv_2015\": \"FLOAT\", \"tiv_2016\": \"FLOAT\", \"lat\": \"FLOAT\", \"lon\": \"FLOAT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)",
|
||||
"Truncate table Insurance",
|
||||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('1', '10', '5', '10', '10')",
|
||||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('2', '20', '20', '20', '20')",
|
||||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('3', '10', '30', '20', '20')",
|
||||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('4', '10', '40', '40', '40')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
90
leetcode/originData/last-person-to-fit-in-the-bus.json
Normal file
90
leetcode/originData/last-person-to-fit-in-the-bus.json
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1327",
|
||||
"questionFrontendId": "1204",
|
||||
"boundTopicId": null,
|
||||
"title": "Last Person to Fit in the Bus",
|
||||
"titleSlug": "last-person-to-fit-in-the-bus",
|
||||
"content": "<p>Table: <code>Queue</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| person_id | int |\n| person_name | varchar |\n| weight | int |\n| turn | int |\n+-------------+---------+\nperson_id column contains unique values.\nThis table has the information about all people waiting for a bus.\nThe person_id and turn columns will contain all numbers from 1 to n, where n is the number of rows in the table.\nturn determines the order of which the people will board the bus, where turn=1 denotes the first person to board and turn=n denotes the last person to board.\nweight is the weight of the person in kilograms.\n</pre>\n\n<p> </p>\n\n<p>There is a queue of people waiting to board a bus. However, the bus has a weight limit of <code>1000</code><strong> kilograms</strong>, so there may be some people who cannot board.</p>\n\n<p>Write a solution to find the <code>person_name</code> of the <strong>last person</strong> that can fit on the bus without exceeding the weight limit. The test cases are generated such that the first person does not exceed the weight limit.</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> \nQueue table:\n+-----------+-------------+--------+------+\n| person_id | person_name | weight | turn |\n+-----------+-------------+--------+------+\n| 5 | Alice | 250 | 1 |\n| 4 | Bob | 175 | 5 |\n| 3 | Alex | 350 | 2 |\n| 6 | John Cena | 400 | 3 |\n| 1 | Winston | 500 | 6 |\n| 2 | Marie | 200 | 4 |\n+-----------+-------------+--------+------+\n<strong>Output:</strong> \n+-------------+\n| person_name |\n+-------------+\n| John Cena |\n+-------------+\n<strong>Explanation:</strong> The folowing table is ordered by the turn for simplicity.\n+------+----+-----------+--------+--------------+\n| Turn | ID | Name | Weight | Total Weight |\n+------+----+-----------+--------+--------------+\n| 1 | 5 | Alice | 250 | 250 |\n| 2 | 3 | Alex | 350 | 600 |\n| 3 | 6 | John Cena | 400 | 1000 | (last person to board)\n| 4 | 2 | Marie | 200 | 1200 | (cannot board)\n| 5 | 4 | Bob | 175 | ___ |\n| 6 | 1 | Winston | 500 | ___ |\n+------+----+-----------+--------+--------------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 564,
|
||||
"dislikes": 25,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Running Total for Different Genders\", \"titleSlug\": \"running-total-for-different-genders\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"The Number of Seniors and Juniors to Join the Company\", \"titleSlug\": \"the-number-of-seniors-and-juniors-to-join-the-company\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"The Number of Seniors and Juniors to Join the Company II\", \"titleSlug\": \"the-number-of-seniors-and-juniors-to-join-the-company-ii\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Queue\":[\"person_id\",\"person_name\",\"weight\",\"turn\"]},\"rows\":{\"Queue\":[[5,\"Alice\",250,1],[4,\"Bob\",175,5],[3,\"Alex\",350,2],[6,\"John Cena\",400,3],[1,\"Winston\",500,6],[2,\"Marie\",200,4]]}}",
|
||||
"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 last_passenger(queue: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"72.6K\", \"totalSubmission\": \"109.7K\", \"totalAcceptedRaw\": 72614, \"totalSubmissionRaw\": 109723, \"acRate\": \"66.2%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Queue\":[\"person_id\",\"person_name\",\"weight\",\"turn\"]},\"rows\":{\"Queue\":[[5,\"Alice\",250,1],[4,\"Bob\",175,5],[3,\"Alex\",350,2],[6,\"John Cena\",400,3],[1,\"Winston\",500,6],[2,\"Marie\",200,4]]}}",
|
||||
"metaData": "{\"manual\": false, \"mysql\": [\"Create table If Not Exists Queue (person_id int, person_name varchar(30), weight int, turn int)\"], \"mssql\": [\"Create table Queue (person_id int, person_name varchar(30), weight int, turn int)\"], \"oraclesql\": [\"Create table Queue (person_id int, person_name varchar(30), weight int, turn int)\"], \"database\": true, \"name\": \"last_passenger\", \"pythondata\": [\"Queue = pd.DataFrame([], columns=['person_id', 'person_name', 'weight', 'turn']).astype({'person_id':'Int64', 'person_name':'object', 'weight':'Int64', 'turn':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Queue (person_id int, person_name varchar(30), weight int, turn int)\"], \"database_schema\": {\"Queue\": {\"person_id\": \"INT\", \"person_name\": \"VARCHAR(30)\", \"weight\": \"INT\", \"turn\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Queue (person_id int, person_name varchar(30), weight int, turn int)",
|
||||
"Truncate table Queue",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('5', 'Alice', '250', '1')",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('4', 'Bob', '175', '5')",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('3', 'Alex', '350', '2')",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('6', 'John Cena', '400', '3')",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('1', 'Winston', '500', '6')",
|
||||
"insert into Queue (person_id, person_name, weight, turn) values ('2', 'Marie', '200', '4')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
103
leetcode/originData/list-the-products-ordered-in-a-period.json
Normal file
103
leetcode/originData/list-the-products-ordered-in-a-period.json
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1462",
|
||||
"questionFrontendId": "1327",
|
||||
"boundTopicId": null,
|
||||
"title": "List the Products Ordered in a Period",
|
||||
"titleSlug": "list-the-products-ordered-in-a-period",
|
||||
"content": "<p>Table: <code>Products</code></p>\n\n<pre>\n+------------------+---------+\n| Column Name | Type |\n+------------------+---------+\n| product_id | int |\n| product_name | varchar |\n| product_category | varchar |\n+------------------+---------+\nproduct_id is the primary key (column with unique values) for this table.\nThis table contains data about the company's products.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Orders</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| product_id | int |\n| order_date | date |\n| unit | int |\n+---------------+---------+\nThis table may have duplicate rows.\nproduct_id is a foreign key (reference column) to the Products table.\nunit is the number of products ordered in order_date.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to get the names of products that have at least <code>100</code> units ordered in <strong>February 2020</strong> and their amount.</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> \nProducts table:\n+-------------+-----------------------+------------------+\n| product_id | product_name | product_category |\n+-------------+-----------------------+------------------+\n| 1 | Leetcode Solutions | Book |\n| 2 | Jewels of Stringology | Book |\n| 3 | HP | Laptop |\n| 4 | Lenovo | Laptop |\n| 5 | Leetcode Kit | T-shirt |\n+-------------+-----------------------+------------------+\nOrders table:\n+--------------+--------------+----------+\n| product_id | order_date | unit |\n+--------------+--------------+----------+\n| 1 | 2020-02-05 | 60 |\n| 1 | 2020-02-10 | 70 |\n| 2 | 2020-01-18 | 30 |\n| 2 | 2020-02-11 | 80 |\n| 3 | 2020-02-17 | 2 |\n| 3 | 2020-02-24 | 3 |\n| 4 | 2020-03-01 | 20 |\n| 4 | 2020-03-04 | 30 |\n| 4 | 2020-03-04 | 60 |\n| 5 | 2020-02-25 | 50 |\n| 5 | 2020-02-27 | 50 |\n| 5 | 2020-03-01 | 50 |\n+--------------+--------------+----------+\n<strong>Output:</strong> \n+--------------------+---------+\n| product_name | unit |\n+--------------------+---------+\n| Leetcode Solutions | 130 |\n| Leetcode Kit | 100 |\n+--------------------+---------+\n<strong>Explanation:</strong> \nProducts with product_id = 1 is ordered in February a total of (60 + 70) = 130.\nProducts with product_id = 2 is ordered in February a total of 80.\nProducts with product_id = 3 is ordered in February a total of (2 + 3) = 5.\nProducts with product_id = 4 was not ordered in February 2020.\nProducts with product_id = 5 is ordered in February a total of (50 + 50) = 100.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 294,
|
||||
"dislikes": 33,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\": {\"Products\": [\"product_id\", \"product_name\", \"product_category\"], \"Orders\": [\"product_id\", \"order_date\", \"unit\"]}, \"rows\": {\"Products\": [[1, \"Leetcode Solutions\", \"Book\"], [2, \"Jewels of Stringology\", \"Book\"], [3, \"HP\", \"Laptop\"], [4, \"Lenovo\", \"Laptop\"], [5, \"Leetcode Kit\", \"T-shirt\"]], \"Orders\": [[1, \"2020-02-05\", 60], [1, \"2020-02-10\", 70], [2, \"2020-01-18\", 30], [2, \"2020-02-11\", 80], [3, \"2020-02-17\", 2], [3, \"2020-02-24\", 3], [4, \"2020-03-01\", 20], [4, \"2020-03-04\", 30], [4, \"2020-03-04\", 60], [5, \"2020-02-25\", 50], [5, \"2020-02-27\", 50], [5, \"2020-03-01\", 50]]}}",
|
||||
"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 list_products(products: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"72.6K\", \"totalSubmission\": \"103.9K\", \"totalAcceptedRaw\": 72600, \"totalSubmissionRaw\": 103857, \"acRate\": \"69.9%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\": {\"Products\": [\"product_id\", \"product_name\", \"product_category\"], \"Orders\": [\"product_id\", \"order_date\", \"unit\"]}, \"rows\": {\"Products\": [[1, \"Leetcode Solutions\", \"Book\"], [2, \"Jewels of Stringology\", \"Book\"], [3, \"HP\", \"Laptop\"], [4, \"Lenovo\", \"Laptop\"], [5, \"Leetcode Kit\", \"T-shirt\"]], \"Orders\": [[1, \"2020-02-05\", 60], [1, \"2020-02-10\", 70], [2, \"2020-01-18\", 30], [2, \"2020-02-11\", 80], [3, \"2020-02-17\", 2], [3, \"2020-02-24\", 3], [4, \"2020-03-01\", 20], [4, \"2020-03-04\", 30], [4, \"2020-03-04\", 60], [5, \"2020-02-25\", 50], [5, \"2020-02-27\", 50], [5, \"2020-03-01\", 50]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Products (product_id int, product_name varchar(40), product_category varchar(40))\", \"Create table If Not Exists Orders (product_id int, order_date date, unit int)\"], \"mssql\": [\"Create table Products (product_id int, product_name varchar(40), product_category varchar(40))\\n\", \"Create table Orders (product_id int, order_date date, unit int)\"], \"oraclesql\": [\"Create table Products (product_id int, product_name varchar(40), product_category varchar(40))\", \"Create table Orders (product_id int, order_date date, unit int)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"list_products\", \"pythondata\": [\"Products = pd.DataFrame([], columns=['product_id', 'product_name', 'product_category']).astype({'product_id':'Int64', 'product_name':'object', 'product_category':'object'})\", \"Orders = pd.DataFrame([], columns=['product_id', 'order_date', 'unit']).astype({'product_id':'Int64', 'order_date':'datetime64[ns]', 'unit':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Products (product_id int, product_name varchar(40), product_category varchar(40))\", \"Create table If Not Exists Orders (product_id int, order_date date, unit int)\"], \"database_schema\": {\"Products\": {\"product_id\": \"INT\", \"product_name\": \"VARCHAR(40)\", \"product_category\": \"VARCHAR(40)\"}, \"Orders\": {\"product_id\": \"INT\", \"order_date\": \"DATE\", \"unit\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Products (product_id int, product_name varchar(40), product_category varchar(40))",
|
||||
"Create table If Not Exists Orders (product_id int, order_date date, unit int)",
|
||||
"Truncate table Products",
|
||||
"insert into Products (product_id, product_name, product_category) values ('1', 'Leetcode Solutions', 'Book')",
|
||||
"insert into Products (product_id, product_name, product_category) values ('2', 'Jewels of Stringology', 'Book')",
|
||||
"insert into Products (product_id, product_name, product_category) values ('3', 'HP', 'Laptop')",
|
||||
"insert into Products (product_id, product_name, product_category) values ('4', 'Lenovo', 'Laptop')",
|
||||
"insert into Products (product_id, product_name, product_category) values ('5', 'Leetcode Kit', 'T-shirt')",
|
||||
"Truncate table Orders",
|
||||
"insert into Orders (product_id, order_date, unit) values ('1', '2020-02-05', '60')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('1', '2020-02-10', '70')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('2', '2020-01-18', '30')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('2', '2020-02-11', '80')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('3', '2020-02-17', '2')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('3', '2020-02-24', '3')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('4', '2020-03-01', '20')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('4', '2020-03-04', '30')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('4', '2020-03-04', '60')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('5', '2020-02-25', '50')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('5', '2020-02-27', '50')",
|
||||
"insert into Orders (product_id, order_date, unit) values ('5', '2020-03-01', '50')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
102
leetcode/originData/managers-with-at-least-5-direct-reports.json
Normal file
102
leetcode/originData/managers-with-at-least-5-direct-reports.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "570",
|
||||
"questionFrontendId": "570",
|
||||
"boundTopicId": null,
|
||||
"title": "Managers with at Least 5 Direct Reports",
|
||||
"titleSlug": "managers-with-at-least-5-direct-reports",
|
||||
"content": "<p>Table: <code>Employee</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| id | int |\n| name | varchar |\n| department | varchar |\n| managerId | int |\n+-------------+---------+\nid is the primary key (column with unique values) for this table.\nEach row of this table indicates the name of an employee, their department, and the id of their manager.\nIf managerId is null, then the employee does not have a manager.\nNo employee will be the manager of themself.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find managers with at least <strong>five direct reports</strong>.</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> \nEmployee table:\n+-----+-------+------------+-----------+\n| id | name | department | managerId |\n+-----+-------+------------+-----------+\n| 101 | John | A | null |\n| 102 | Dan | A | 101 |\n| 103 | James | A | 101 |\n| 104 | Amy | A | 101 |\n| 105 | Anne | A | 101 |\n| 106 | Ron | B | 101 |\n+-----+-------+------------+-----------+\n<strong>Output:</strong> \n+------+\n| name |\n+------+\n| John |\n+------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 844,
|
||||
"dislikes": 88,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\": {\"Employee\": [\"id\", \"name\", \"department\", \"managerId\"]}, \"rows\": {\"Employee\": [[101, \"John\", \"A\", null],[102, \"Dan\", \"A\", 101], [103, \"James\", \"A\", 101], [104, \"Amy\", \"A\", 101], [105, \"Anne\", \"A\", 101], [106, \"Ron\", \"B\", 101]]}}",
|
||||
"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_managers(employee: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"200.7K\", \"totalSubmission\": \"375.2K\", \"totalAcceptedRaw\": 200742, \"totalSubmissionRaw\": 375208, \"acRate\": \"53.5%\"}",
|
||||
"hints": [
|
||||
"Try to get all the mangerIDs that have count bigger than 5",
|
||||
"Use the last hint's result as a table and do join with origin table at id equals to managerId",
|
||||
"This is a very good example to show the performance of SQL code. Try to work out other solutions and you may be surprised by running time difference.",
|
||||
"If your solution uses 'IN' function and runs more than 5 seconds, try to optimize it by using 'JOIN' instead."
|
||||
],
|
||||
"solution": {
|
||||
"id": "209",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\": {\"Employee\": [\"id\", \"name\", \"department\", \"managerId\"]}, \"rows\": {\"Employee\": [[101, \"John\", \"A\", null],[102, \"Dan\", \"A\", 101], [103, \"James\", \"A\", 101], [104, \"Amy\", \"A\", 101], [105, \"Anne\", \"A\", 101], [106, \"Ron\", \"B\", 101]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employee (id int, name varchar(255), department varchar(255), managerId int)\"], \"mssql\": [\"Create table Employee (id int, name varchar(255), department varchar(255), managerId int)\"], \"oraclesql\": [\"Create table Employee (id int, name varchar(255), department varchar(255), managerId int)\"], \"database\": true, \"name\": \"find_managers\", \"pythondata\": [\"Employee = pd.DataFrame([], columns=['id', 'name', 'department', 'managerId']).astype({'id':'Int64', 'name':'object', 'department':'object', 'managerId':'Int64'})\"], \"manual\": false, \"postgresql\": [\"\\nCreate table If Not Exists Employee (id int, name varchar(255), department varchar(255), managerId int)\"], \"database_schema\": {\"Employee\": {\"id\": \"INT\", \"name\": \"VARCHAR(255)\", \"department\": \"VARCHAR(255)\", \"managerId\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employee (id int, name varchar(255), department varchar(255), managerId int)",
|
||||
"Truncate table Employee",
|
||||
"insert into Employee (id, name, department, managerId) values ('101', 'John', 'A', 'None')",
|
||||
"insert into Employee (id, name, department, managerId) values ('102', 'Dan', 'A', '101')",
|
||||
"insert into Employee (id, name, department, managerId) values ('103', 'James', 'A', '101')",
|
||||
"insert into Employee (id, name, department, managerId) values ('104', 'Amy', 'A', '101')",
|
||||
"insert into Employee (id, name, department, managerId) values ('105', 'Anne', 'A', '101')",
|
||||
"insert into Employee (id, name, department, managerId) values ('106', 'Ron', 'B', '101')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
88
leetcode/originData/monthly-transactions-i.json
Normal file
88
leetcode/originData/monthly-transactions-i.json
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1317",
|
||||
"questionFrontendId": "1193",
|
||||
"boundTopicId": null,
|
||||
"title": "Monthly Transactions I",
|
||||
"titleSlug": "monthly-transactions-i",
|
||||
"content": "<p>Table: <code>Transactions</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| id | int |\n| country | varchar |\n| state | enum |\n| amount | int |\n| trans_date | date |\n+---------------+---------+\nid is the primary key of this table.\nThe table has information about incoming transactions.\nThe state column is an enum of type ["approved", "declined"].\n</pre>\n\n<p> </p>\n\n<p>Write an SQL query to find for each month and country, the number of transactions and their total amount, the number of approved transactions and their total amount.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The query 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> \nTransactions table:\n+------+---------+----------+--------+------------+\n| id | country | state | amount | trans_date |\n+------+---------+----------+--------+------------+\n| 121 | US | approved | 1000 | 2018-12-18 |\n| 122 | US | declined | 2000 | 2018-12-19 |\n| 123 | US | approved | 2000 | 2019-01-01 |\n| 124 | DE | approved | 2000 | 2019-01-07 |\n+------+---------+----------+--------+------------+\n<strong>Output:</strong> \n+----------+---------+-------------+----------------+--------------------+-----------------------+\n| month | country | trans_count | approved_count | trans_total_amount | approved_total_amount |\n+----------+---------+-------------+----------------+--------------------+-----------------------+\n| 2018-12 | US | 2 | 1 | 3000 | 1000 |\n| 2019-01 | US | 1 | 1 | 2000 | 2000 |\n| 2019-01 | DE | 1 | 1 | 2000 | 2000 |\n+----------+---------+-------------+----------------+--------------------+-----------------------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 614,
|
||||
"dislikes": 46,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Monthly Transactions II\", \"titleSlug\": \"monthly-transactions-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Transactions\":[\"id\",\"country\",\"state\",\"amount\",\"trans_date\"]},\"rows\":{\"Transactions\":[[121,\"US\",\"approved\",1000,\"2018-12-18\"],[122,\"US\",\"declined\",2000,\"2018-12-19\"],[123,\"US\",\"approved\",2000,\"2019-01-01\"],[124,\"DE\",\"approved\",2000,\"2019-01-07\"]]}}",
|
||||
"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 monthly_transactions(transactions: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"96.5K\", \"totalSubmission\": \"163.7K\", \"totalAcceptedRaw\": 96550, \"totalSubmissionRaw\": 163698, \"acRate\": \"59.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Transactions\":[\"id\",\"country\",\"state\",\"amount\",\"trans_date\"]},\"rows\":{\"Transactions\":[[121,\"US\",\"approved\",1000,\"2018-12-18\"],[122,\"US\",\"declined\",2000,\"2018-12-19\"],[123,\"US\",\"approved\",2000,\"2019-01-01\"],[124,\"DE\",\"approved\",2000,\"2019-01-07\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date)\"], \"mssql\": [\"Create table Transactions (id int, country varchar(4), state varchar(10) check(state in ('approved', 'declined')), amount int, trans_date date)\"], \"oraclesql\": [\"Create table Transactions (id int, country varchar(4), state varchar(10) check(state in ('approved', 'declined')), amount int, trans_date date)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"monthly_transactions\", \"pythondata\": [\"Transactions = pd.DataFrame([], columns=['id', 'country', 'state', 'amount', 'trans_date']).astype({'id':'Int64', 'country':'object', 'state':'object', 'amount':'Int64', 'trans_date':'datetime64[ns]'})\"], \"postgresql\": [\"Create table If Not Exists Transactions (id int, country varchar(4), state VARCHAR(30) CHECK (state IN ('approved', 'declined')), amount int, trans_date date)\\n\\n\"], \"database_schema\": {\"Transactions\": {\"id\": \"INT\", \"country\": \"VARCHAR(4)\", \"state\": \"ENUM('approved', 'declined')\", \"amount\": \"INT\", \"trans_date\": \"DATE\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date)",
|
||||
"Truncate table Transactions",
|
||||
"insert into Transactions (id, country, state, amount, trans_date) values ('121', 'US', 'approved', '1000', '2018-12-18')",
|
||||
"insert into Transactions (id, country, state, amount, trans_date) values ('122', 'US', 'declined', '2000', '2018-12-19')",
|
||||
"insert into Transactions (id, country, state, amount, trans_date) values ('123', 'US', 'approved', '2000', '2019-01-01')",
|
||||
"insert into Transactions (id, country, state, amount, trans_date) values ('124', 'DE', 'approved', '2000', '2019-01-07')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
104
leetcode/originData/movie-rating.json
Normal file
104
leetcode/originData/movie-rating.json
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1480",
|
||||
"questionFrontendId": "1341",
|
||||
"boundTopicId": null,
|
||||
"title": "Movie Rating",
|
||||
"titleSlug": "movie-rating",
|
||||
"content": "<p>Table: <code>Movies</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| movie_id | int |\n| title | varchar |\n+---------------+---------+\nmovie_id is the primary key (column with unique values) for this table.\ntitle is the name of the movie.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Users</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| user_id | int |\n| name | varchar |\n+---------------+---------+\nuser_id is the primary key (column with unique values) for this table.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>MovieRating</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| movie_id | int |\n| user_id | int |\n| rating | int |\n| created_at | date |\n+---------------+---------+\n(movie_id, user_id) is the primary key (column with unique values) for this table.\nThis table contains the rating of a movie by a user in their review.\ncreated_at is the user's review date. \n</pre>\n\n<p> </p>\n\n<p>Write a solution to:</p>\n\n<ul>\n\t<li>Find the name of the user who has rated the greatest number of movies. In case of a tie, return the lexicographically smaller user name.</li>\n\t<li>Find the movie name with the <strong>highest average</strong> rating in <code>February 2020</code>. In case of a tie, return the lexicographically smaller movie name.</li>\n</ul>\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> \nMovies table:\n+-------------+--------------+\n| movie_id | title |\n+-------------+--------------+\n| 1 | Avengers |\n| 2 | Frozen 2 |\n| 3 | Joker |\n+-------------+--------------+\nUsers table:\n+-------------+--------------+\n| user_id | name |\n+-------------+--------------+\n| 1 | Daniel |\n| 2 | Monica |\n| 3 | Maria |\n| 4 | James |\n+-------------+--------------+\nMovieRating table:\n+-------------+--------------+--------------+-------------+\n| movie_id | user_id | rating | created_at |\n+-------------+--------------+--------------+-------------+\n| 1 | 1 | 3 | 2020-01-12 |\n| 1 | 2 | 4 | 2020-02-11 |\n| 1 | 3 | 2 | 2020-02-12 |\n| 1 | 4 | 1 | 2020-01-01 |\n| 2 | 1 | 5 | 2020-02-17 | \n| 2 | 2 | 2 | 2020-02-01 | \n| 2 | 3 | 2 | 2020-03-01 |\n| 3 | 1 | 3 | 2020-02-22 | \n| 3 | 2 | 4 | 2020-02-25 | \n+-------------+--------------+--------------+-------------+\n<strong>Output:</strong> \n+--------------+\n| results |\n+--------------+\n| Daniel |\n| Frozen 2 |\n+--------------+\n<strong>Explanation:</strong> \nDaniel and Monica have rated 3 movies ("Avengers", "Frozen 2" and "Joker") but Daniel is smaller lexicographically.\nFrozen 2 and Joker have a rating average of 3.5 in February but Frozen 2 is smaller lexicographically.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 418,
|
||||
"dislikes": 148,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\": {\"Movies\": [\"movie_id\", \"title\"], \"Users\": [\"user_id\", \"name\"], \"MovieRating\": [\"movie_id\", \"user_id\", \"rating\", \"created_at\"]}, \"rows\": {\"Movies\": [[1, \"Avengers\"], [2, \"Frozen 2\"], [3, \"Joker\"]], \"Users\": [[1, \"Daniel\"], [2, \"Monica\"], [3, \"Maria\"], [4, \"James\"]], \"MovieRating\": [[1, 1, 3, \"2020-01-12\"], [1, 2, 4, \"2020-02-11\"], [1, 3, 2, \"2020-02-12\"], [1, 4, 1, \"2020-01-01\"], [2, 1, 5, \"2020-02-17\"], [2, 2, 2, \"2020-02-01\"], [2, 3, 2, \"2020-03-01\"], [3, 1, 3, \"2020-02-22\"], [3, 2, 4, \"2020-02-25\"]]}}",
|
||||
"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 movie_rating(movies: pd.DataFrame, users: pd.DataFrame, movie_rating: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"56.5K\", \"totalSubmission\": \"139K\", \"totalAcceptedRaw\": 56477, \"totalSubmissionRaw\": 139022, \"acRate\": \"40.6%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\": {\"Movies\": [\"movie_id\", \"title\"], \"Users\": [\"user_id\", \"name\"], \"MovieRating\": [\"movie_id\", \"user_id\", \"rating\", \"created_at\"]}, \"rows\": {\"Movies\": [[1, \"Avengers\"], [2, \"Frozen 2\"], [3, \"Joker\"]], \"Users\": [[1, \"Daniel\"], [2, \"Monica\"], [3, \"Maria\"], [4, \"James\"]], \"MovieRating\": [[1, 1, 3, \"2020-01-12\"], [1, 2, 4, \"2020-02-11\"], [1, 3, 2, \"2020-02-12\"], [1, 4, 1, \"2020-01-01\"], [2, 1, 5, \"2020-02-17\"], [2, 2, 2, \"2020-02-01\"], [2, 3, 2, \"2020-03-01\"], [3, 1, 3, \"2020-02-22\"], [3, 2, 4, \"2020-02-25\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Movies (movie_id int, title varchar(30))\", \"Create table If Not Exists Users (user_id int, name varchar(30))\", \"Create table If Not Exists MovieRating (movie_id int, user_id int, rating int, created_at date)\"], \"mssql\": [\"Create table Movies (movie_id int, title varchar(30))\", \"Create table Users (user_id int, name varchar(30))\", \"Create table MovieRating (movie_id int, user_id int, rating int, created_at date)\"], \"oraclesql\": [\"Create table Movies (movie_id int, title varchar(30))\", \"Create table Users (user_id int, name varchar(30))\", \"Create table MovieRating (movie_id int, user_id int, rating int, created_at date)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"movie_rating\", \"pythondata\": [\"Movies = pd.DataFrame([], columns=['movie_id', 'title']).astype({'movie_id':'Int64', 'title':'object'})\", \"Users = pd.DataFrame([], columns=['user_id', 'name']).astype({'user_id':'Int64', 'name':'object'})\", \"MovieRating = pd.DataFrame([], columns=['movie_id', 'user_id', 'rating', 'created_at']).astype({'movie_id':'Int64', 'user_id':'Int64', 'rating':'Int64', 'created_at':'datetime64[ns]'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Movies (movie_id int, title varchar(30))\", \"Create table If Not Exists Users (user_id int, name varchar(30))\", \"Create table If Not Exists MovieRating (movie_id int, user_id int, rating int, created_at date)\"], \"database_schema\": {\"Movies\": {\"movie_id\": \"INT\", \"title\": \"VARCHAR(30)\"}, \"Users\": {\"user_id\": \"INT\", \"name\": \"VARCHAR(30)\"}, \"MovieRating\": {\"movie_id\": \"INT\", \"user_id\": \"INT\", \"rating\": \"INT\", \"created_at\": \"DATE\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Movies (movie_id int, title varchar(30))",
|
||||
"Create table If Not Exists Users (user_id int, name varchar(30))",
|
||||
"Create table If Not Exists MovieRating (movie_id int, user_id int, rating int, created_at date)",
|
||||
"Truncate table Movies",
|
||||
"insert into Movies (movie_id, title) values ('1', 'Avengers')",
|
||||
"insert into Movies (movie_id, title) values ('2', 'Frozen 2')",
|
||||
"insert into Movies (movie_id, title) values ('3', 'Joker')",
|
||||
"Truncate table Users",
|
||||
"insert into Users (user_id, name) values ('1', 'Daniel')",
|
||||
"insert into Users (user_id, name) values ('2', 'Monica')",
|
||||
"insert into Users (user_id, name) values ('3', 'Maria')",
|
||||
"insert into Users (user_id, name) values ('4', 'James')",
|
||||
"Truncate table MovieRating",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '1', '3', '2020-01-12')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '2', '4', '2020-02-11')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '3', '2', '2020-02-12')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '4', '1', '2020-01-01')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '1', '5', '2020-02-17')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '2', '2', '2020-02-01')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '3', '2', '2020-03-01')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('3', '1', '3', '2020-02-22')",
|
||||
"insert into MovieRating (movie_id, user_id, rating, created_at) values ('3', '2', '4', '2020-02-25')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2495",
|
||||
"questionFrontendId": "2356",
|
||||
"boundTopicId": null,
|
||||
"title": "Number of Unique Subjects Taught by Each Teacher",
|
||||
"titleSlug": "number-of-unique-subjects-taught-by-each-teacher",
|
||||
"content": "<p>Table: <code>Teacher</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| teacher_id | int |\n| subject_id | int |\n| dept_id | int |\n+-------------+------+\n(subject_id, dept_id) is the primary key (combinations of columns with unique values) of this table.\nEach row in this table indicates that the teacher with teacher_id teaches the subject subject_id in the department dept_id.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to calculate the number of unique subjects each teacher teaches in the university.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The result format is shown 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> \nTeacher table:\n+------------+------------+---------+\n| teacher_id | subject_id | dept_id |\n+------------+------------+---------+\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 1 | 3 | 3 |\n| 2 | 1 | 1 |\n| 2 | 2 | 1 |\n| 2 | 3 | 1 |\n| 2 | 4 | 1 |\n+------------+------------+---------+\n<strong>Output:</strong> \n+------------+-----+\n| teacher_id | cnt |\n+------------+-----+\n| 1 | 2 |\n| 2 | 4 |\n+------------+-----+\n<strong>Explanation:</strong> \nTeacher 1:\n - They teach subject 2 in departments 3 and 4.\n - They teach subject 3 in department 3.\nTeacher 2:\n - They teach subject 1 in department 1.\n - They teach subject 2 in department 1.\n - They teach subject 3 in department 1.\n - They teach subject 4 in department 1.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 322,
|
||||
"dislikes": 19,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Teacher\":[\"teacher_id\",\"subject_id\",\"dept_id\"]},\"rows\":{\"Teacher\":[[1,2,3],[1,2,4],[1,3,3],[2,1,1],[2,2,1],[2,3,1],[2,4,1]]}}",
|
||||
"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 count_unique_subjects(teacher: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"79.1K\", \"totalSubmission\": \"91.4K\", \"totalAcceptedRaw\": 79054, \"totalSubmissionRaw\": 91409, \"acRate\": \"86.5%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2014",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Teacher\":[\"teacher_id\",\"subject_id\",\"dept_id\"]},\"rows\":{\"Teacher\":[[1,2,3],[1,2,4],[1,3,3],[2,1,1],[2,2,1],[2,3,1],[2,4,1]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)\"], \"mssql\": [\"Create table Teacher (teacher_id int, subject_id int, dept_id int)\"], \"oraclesql\": [\"Create table Teacher (teacher_id int, subject_id int, dept_id int)\"], \"database\": true, \"name\": \"count_unique_subjects\", \"pythondata\": [\"Teacher = pd.DataFrame([], columns=['teacher_id', 'subject_id', 'dept_id']).astype({'teacher_id':'Int64', 'subject_id':'Int64', 'dept_id':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)\"], \"database_schema\": {\"Teacher\": {\"teacher_id\": \"INT\", \"subject_id\": \"INT\", \"dept_id\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)",
|
||||
"Truncate table Teacher",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '2', '3')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '2', '4')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '3', '3')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '1', '1')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '2', '1')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '3', '1')",
|
||||
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '4', '1')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
101
leetcode/originData/percentage-of-users-attended-a-contest.json
Normal file
101
leetcode/originData/percentage-of-users-attended-a-contest.json
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1773",
|
||||
"questionFrontendId": "1633",
|
||||
"boundTopicId": null,
|
||||
"title": "Percentage of Users Attended a Contest",
|
||||
"titleSlug": "percentage-of-users-attended-a-contest",
|
||||
"content": "<p>Table: <code>Users</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| user_id | int |\n| user_name | varchar |\n+-------------+---------+\nuser_id is the primary key (column with unique values) for this table.\nEach row of this table contains the name and the id of a user.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Register</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| contest_id | int |\n| user_id | int |\n+-------------+---------+\n(contest_id, user_id) is the primary key (combination of columns with unique values) for this table.\nEach row of this table contains the id of a user and the contest they registered into.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the percentage of the users registered in each contest rounded to <strong>two decimals</strong>.</p>\n\n<p>Return the result table ordered by <code>percentage</code> in <strong>descending order</strong>. In case of a tie, order it by <code>contest_id</code> in <strong>ascending 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> \nUsers table:\n+---------+-----------+\n| user_id | user_name |\n+---------+-----------+\n| 6 | Alice |\n| 2 | Bob |\n| 7 | Alex |\n+---------+-----------+\nRegister table:\n+------------+---------+\n| contest_id | user_id |\n+------------+---------+\n| 215 | 6 |\n| 209 | 2 |\n| 208 | 2 |\n| 210 | 6 |\n| 208 | 6 |\n| 209 | 7 |\n| 209 | 6 |\n| 215 | 7 |\n| 208 | 7 |\n| 210 | 2 |\n| 207 | 2 |\n| 210 | 7 |\n+------------+---------+\n<strong>Output:</strong> \n+------------+------------+\n| contest_id | percentage |\n+------------+------------+\n| 208 | 100.0 |\n| 209 | 100.0 |\n| 210 | 100.0 |\n| 215 | 66.67 |\n| 207 | 33.33 |\n+------------+------------+\n<strong>Explanation:</strong> \nAll the users registered in contests 208, 209, and 210. The percentage is 100% and we sort them in the answer table by contest_id in ascending order.\nAlice and Alex registered in contest 215 and the percentage is ((2/3) * 100) = 66.67%\nBob registered in contest 207 and the percentage is ((1/3) * 100) = 33.33%\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 483,
|
||||
"dislikes": 46,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Queries Quality and Percentage\", \"titleSlug\": \"queries-quality-and-percentage\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Users\":[\"user_id\",\"user_name\"],\"Register\":[\"contest_id\",\"user_id\"]},\"rows\":{\"Users\":[[6,\"Alice\"],[2,\"Bob\"],[7,\"Alex\"]],\"Register\":[[215,6],[209,2],[208,2],[210,6],[208,6],[209,7],[209,6],[215,7],[208,7],[210,2],[207,2],[210,7]]}}",
|
||||
"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 users_percentage(users: pd.DataFrame, register: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"90.7K\", \"totalSubmission\": \"160.8K\", \"totalAcceptedRaw\": 90686, \"totalSubmissionRaw\": 160840, \"acRate\": \"56.4%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Users\":[\"user_id\",\"user_name\"],\"Register\":[\"contest_id\",\"user_id\"]},\"rows\":{\"Users\":[[6,\"Alice\"],[2,\"Bob\"],[7,\"Alex\"]],\"Register\":[[215,6],[209,2],[208,2],[210,6],[208,6],[209,7],[209,6],[215,7],[208,7],[210,2],[207,2],[210,7]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Users (user_id int, user_name varchar(20))\", \"Create table If Not Exists Register (contest_id int, user_id int)\"], \"mssql\": [\"Create table Users (user_id int, user_name varchar(20))\", \"Create table Register (contest_id int, user_id int)\"], \"oraclesql\": [\"Create table Users (user_id int, user_name varchar(20))\", \"Create table Register (contest_id int, user_id int)\"], \"database\": true, \"name\": \"users_percentage\", \"pythondata\": [\"Users = pd.DataFrame([], columns=['user_id', 'user_name']).astype({'user_id':'Int64', 'user_name':'object'})\", \"Register = pd.DataFrame([], columns=['contest_id', 'user_id']).astype({'contest_id':'Int64', 'user_id':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Users (user_id int, user_name varchar(20))\\n\", \"Create table If Not Exists Register (contest_id int, user_id int)\"], \"database_schema\": {\"Users\": {\"user_id\": \"INT\", \"user_name\": \"VARCHAR(20)\"}, \"Register\": {\"contest_id\": \"INT\", \"user_id\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Users (user_id int, user_name varchar(20))",
|
||||
"Create table If Not Exists Register (contest_id int, user_id int)",
|
||||
"Truncate table Users",
|
||||
"insert into Users (user_id, user_name) values ('6', 'Alice')",
|
||||
"insert into Users (user_id, user_name) values ('2', 'Bob')",
|
||||
"insert into Users (user_id, user_name) values ('7', 'Alex')",
|
||||
"Truncate table Register",
|
||||
"insert into Register (contest_id, user_id) values ('215', '6')",
|
||||
"insert into Register (contest_id, user_id) values ('209', '2')",
|
||||
"insert into Register (contest_id, user_id) values ('208', '2')",
|
||||
"insert into Register (contest_id, user_id) values ('210', '6')",
|
||||
"insert into Register (contest_id, user_id) values ('208', '6')",
|
||||
"insert into Register (contest_id, user_id) values ('209', '7')",
|
||||
"insert into Register (contest_id, user_id) values ('209', '6')",
|
||||
"insert into Register (contest_id, user_id) values ('215', '7')",
|
||||
"insert into Register (contest_id, user_id) values ('208', '7')",
|
||||
"insert into Register (contest_id, user_id) values ('210', '2')",
|
||||
"insert into Register (contest_id, user_id) values ('207', '2')",
|
||||
"insert into Register (contest_id, user_id) values ('210', '7')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1942",
|
||||
"questionFrontendId": "1789",
|
||||
"boundTopicId": null,
|
||||
"title": "Primary Department for Each Employee",
|
||||
"titleSlug": "primary-department-for-each-employee",
|
||||
"content": "<p>Table: <code>Employee</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| employee_id | int |\n| department_id | int |\n| primary_flag | varchar |\n+---------------+---------+\n(employee_id, department_id) is the primary key (combination of columns with unique values) for this table.\nemployee_id is the id of the employee.\ndepartment_id is the id of the department to which the employee belongs.\nprimary_flag is an ENUM (category) of type ('Y', 'N'). If the flag is 'Y', the department is the primary department for the employee. If the flag is 'N', the department is not the primary.\n</pre>\n\n<p> </p>\n\n<p>Employees can belong to multiple departments. When the employee joins other departments, they need to decide which department is their primary department. Note that when an employee belongs to only one department, their primary column is <code>'N'</code>.</p>\n\n<p>Write a solution to report all the employees with their primary department. For employees who belong to one department, report their only department.</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> \nEmployee table:\n+-------------+---------------+--------------+\n| employee_id | department_id | primary_flag |\n+-------------+---------------+--------------+\n| 1 | 1 | N |\n| 2 | 1 | Y |\n| 2 | 2 | N |\n| 3 | 3 | N |\n| 4 | 2 | N |\n| 4 | 3 | Y |\n| 4 | 4 | N |\n+-------------+---------------+--------------+\n<strong>Output:</strong> \n+-------------+---------------+\n| employee_id | department_id |\n+-------------+---------------+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 3 |\n| 4 | 3 |\n+-------------+---------------+\n<strong>Explanation:</strong> \n- The Primary department for employee 1 is 1.\n- The Primary department for employee 2 is 1.\n- The Primary department for employee 3 is 3.\n- The Primary department for employee 4 is 3.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 346,
|
||||
"dislikes": 151,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Employee\":[\"employee_id\",\"department_id\",\"primary_flag\"]},\"rows\":{\"Employee\":[[\"1\",\"1\",\"N\"],[\"2\",\"1\",\"Y\"],[\"2\",\"2\",\"N\"],[\"3\",\"3\",\"N\"],[\"4\",\"2\",\"N\"],[\"4\",\"3\",\"Y\"],[\"4\",\"4\",\"N\"]]}}",
|
||||
"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_primary_department(employee: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"57.9K\", \"totalSubmission\": \"90K\", \"totalAcceptedRaw\": 57864, \"totalSubmissionRaw\": 90000, \"acRate\": \"64.3%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2057",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Employee\":[\"employee_id\",\"department_id\",\"primary_flag\"]},\"rows\":{\"Employee\":[[\"1\",\"1\",\"N\"],[\"2\",\"1\",\"Y\"],[\"2\",\"2\",\"N\"],[\"3\",\"3\",\"N\"],[\"4\",\"2\",\"N\"],[\"4\",\"3\",\"Y\"],[\"4\",\"4\",\"N\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employee (employee_id int, department_id int, primary_flag ENUM('Y','N'))\"], \"mssql\": [\"Create table Employee (employee_id int, department_id int, primary_flag varchar(1) not null check(primary_flag in ('Y', 'N')))\"], \"oraclesql\": [\"Create table Employee (employee_id int, department_id int, primary_flag varchar(1) not null check(primary_flag in ('Y', 'N')))\"], \"database\": true, \"name\": \"find_primary_department\", \"pythondata\": [\"Employee = pd.DataFrame([], columns=['employee_id', 'department_id', 'primary_flag']).astype({'employee_id':'Int64', 'department_id':'Int64', 'primary_flag':'object'})\"], \"postgresql\": [\"Create table If Not Exists Employee (employee_id int, department_id int, primary_flag VARCHAR(30) CHECK (primary_flag IN ('Y','N')))\\n\"], \"database_schema\": {\"Employee\": {\"employee_id\": \"INT\", \"department_id\": \"INT\", \"primary_flag\": \"ENUM('Y', 'N')\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employee (employee_id int, department_id int, primary_flag ENUM('Y','N'))",
|
||||
"Truncate table Employee",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('1', '1', 'N')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('2', '1', 'Y')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('2', '2', 'N')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('3', '3', 'N')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('4', '2', 'N')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('4', '3', 'Y')",
|
||||
"insert into Employee (employee_id, department_id, primary_flag) values ('4', '4', 'N')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
97
leetcode/originData/product-price-at-a-given-date.json
Normal file
97
leetcode/originData/product-price-at-a-given-date.json
Normal file
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1278",
|
||||
"questionFrontendId": "1164",
|
||||
"boundTopicId": null,
|
||||
"title": "Product Price at a Given Date",
|
||||
"titleSlug": "product-price-at-a-given-date",
|
||||
"content": "<p>Table: <code>Products</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| product_id | int |\n| new_price | int |\n| change_date | date |\n+---------------+---------+\n(product_id, change_date) is the primary key (combination of columns with unique values) of this table.\nEach row of this table indicates that the price of some product was changed to a new price at some date.</pre>\n\n<p> </p>\n\n<p>Write a solution to find the prices of all products on <code>2019-08-16</code>. Assume the price of all products before any change is <code>10</code>.</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> \nProducts table:\n+------------+-----------+-------------+\n| product_id | new_price | change_date |\n+------------+-----------+-------------+\n| 1 | 20 | 2019-08-14 |\n| 2 | 50 | 2019-08-14 |\n| 1 | 30 | 2019-08-15 |\n| 1 | 35 | 2019-08-16 |\n| 2 | 65 | 2019-08-17 |\n| 3 | 20 | 2019-08-18 |\n+------------+-----------+-------------+\n<strong>Output:</strong> \n+------------+-------+\n| product_id | price |\n+------------+-------+\n| 2 | 50 |\n| 1 | 35 |\n| 3 | 10 |\n+------------+-------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 709,
|
||||
"dislikes": 179,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Products\":[\"product_id\",\"new_price\",\"change_date\"]},\"rows\":{\"Products\":[[1,20,\"2019-08-14\"],[2,50,\"2019-08-14\"],[1,30,\"2019-08-15\"],[1,35,\"2019-08-16\"],[2,65,\"2019-08-17\"],[3,20,\"2019-08-18\"]]}}",
|
||||
"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 price_at_given_date(products: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"77K\", \"totalSubmission\": \"137.8K\", \"totalAcceptedRaw\": 77042, \"totalSubmissionRaw\": 137775, \"acRate\": \"55.9%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "1621",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Products\":[\"product_id\",\"new_price\",\"change_date\"]},\"rows\":{\"Products\":[[1,20,\"2019-08-14\"],[2,50,\"2019-08-14\"],[1,30,\"2019-08-15\"],[1,35,\"2019-08-16\"],[2,65,\"2019-08-17\"],[3,20,\"2019-08-18\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Products (product_id int, new_price int, change_date date)\"], \"mssql\": [\"Create table Products (product_id int, new_price int, change_date date)\"], \"oraclesql\": [\"Create table Products (product_id int, new_price int, change_date date)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"price_at_given_date\", \"pythondata\": [\"Products = pd.DataFrame([], columns=['product_id', 'new_price', 'change_date']).astype({'product_id':'Int64', 'new_price':'Int64', 'change_date':'datetime64[ns]'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Products (product_id int, new_price int, change_date date)\"], \"database_schema\": {\"Products\": {\"product_id\": \"INT\", \"new_price\": \"INT\", \"change_date\": \"DATE\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Products (product_id int, new_price int, change_date date)",
|
||||
"Truncate table Products",
|
||||
"insert into Products (product_id, new_price, change_date) values ('1', '20', '2019-08-14')",
|
||||
"insert into Products (product_id, new_price, change_date) values ('2', '50', '2019-08-14')",
|
||||
"insert into Products (product_id, new_price, change_date) values ('1', '30', '2019-08-15')",
|
||||
"insert into Products (product_id, new_price, change_date) values ('1', '35', '2019-08-16')",
|
||||
"insert into Products (product_id, new_price, change_date) values ('2', '65', '2019-08-17')",
|
||||
"insert into Products (product_id, new_price, change_date) values ('3', '20', '2019-08-18')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
99
leetcode/originData/product-sales-analysis-i.json
Normal file
99
leetcode/originData/product-sales-analysis-i.json
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1153",
|
||||
"questionFrontendId": "1068",
|
||||
"boundTopicId": null,
|
||||
"title": "Product Sales Analysis I",
|
||||
"titleSlug": "product-sales-analysis-i",
|
||||
"content": "<p>Table: <code>Sales</code></p>\n\n<pre>\n+-------------+-------+\n| Column Name | Type |\n+-------------+-------+\n| sale_id | int |\n| product_id | int |\n| year | int |\n| quantity | int |\n| price | int |\n+-------------+-------+\n(sale_id, year) is the primary key (combination of columns with unique values) of this table.\nproduct_id is a foreign key (reference column) to <code>Product</code> table.\nEach row of this table shows a sale on the product product_id in a certain year.\nNote that the price is per unit.\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_id | int |\n| product_name | varchar |\n+--------------+---------+\nproduct_id is the primary key (column with unique values) of this table.\nEach row of this table indicates the product name of each product.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to report the <code>product_name</code>, <code>year</code>, and <code>price</code> for each <code>sale_id</code> in the <code>Sales</code> table.</p>\n\n<p>Return the resulting 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> \nSales table:\n+---------+------------+------+----------+-------+\n| sale_id | product_id | year | quantity | price |\n+---------+------------+------+----------+-------+ \n| 1 | 100 | 2008 | 10 | 5000 |\n| 2 | 100 | 2009 | 12 | 5000 |\n| 7 | 200 | 2011 | 15 | 9000 |\n+---------+------------+------+----------+-------+\nProduct table:\n+------------+--------------+\n| product_id | product_name |\n+------------+--------------+\n| 100 | Nokia |\n| 200 | Apple |\n| 300 | Samsung |\n+------------+--------------+\n<strong>Output:</strong> \n+--------------+-------+-------+\n| product_name | year | price |\n+--------------+-------+-------+\n| Nokia | 2008 | 5000 |\n| Nokia | 2009 | 5000 |\n| Apple | 2011 | 9000 |\n+--------------+-------+-------+\n<strong>Explanation:</strong> \nFrom sale_id = 1, we can conclude that Nokia was sold for 5000 in the year 2008.\nFrom sale_id = 2, we can conclude that Nokia was sold for 5000 in the year 2009.\nFrom sale_id = 7, we can conclude that Apple was sold for 9000 in the year 2011.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 620,
|
||||
"dislikes": 195,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Product Sales Analysis II\", \"titleSlug\": \"product-sales-analysis-ii\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Product Sales Analysis IV\", \"titleSlug\": \"product-sales-analysis-iv\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Product Sales Analysis V\", \"titleSlug\": \"product-sales-analysis-v\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Sales\":[\"sale_id\",\"product_id\",\"year\",\"quantity\",\"price\"],\"Product\":[\"product_id\",\"product_name\"]},\"rows\":{\"Sales\":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],\"Product\":[[100,\"Nokia\"],[200,\"Apple\"],[300,\"Samsung\"]]}}",
|
||||
"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 sales_analysis(sales: 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\": \"241K\", \"totalSubmission\": \"298.1K\", \"totalAcceptedRaw\": 241031, \"totalSubmissionRaw\": 298147, \"acRate\": \"80.8%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2044",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Sales\":[\"sale_id\",\"product_id\",\"year\",\"quantity\",\"price\"],\"Product\":[\"product_id\",\"product_name\"]},\"rows\":{\"Sales\":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],\"Product\":[[100,\"Nokia\"],[200,\"Apple\"],[300,\"Samsung\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table If Not Exists Product (product_id int, product_name varchar(10))\"], \"mssql\": [\"Create table Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table Product (product_id int, product_name varchar(10))\"], \"oraclesql\": [\"Create table Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table Product (product_id int, product_name varchar(10))\"], \"database\": true, \"name\": \"sales_analysis\", \"pythondata\": [\"Sales = pd.DataFrame([], columns=['sale_id', 'product_id', 'year', 'quantity', 'price']).astype({'sale_id':'Int64', 'product_id':'Int64', 'year':'Int64', 'quantity':'Int64', 'price':'Int64'})\", \"Product = pd.DataFrame([], columns=['product_id', 'product_name']).astype({'product_id':'Int64', 'product_name':'object'})\"], \"postgresql\": [\"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)\\n\", \"Create table If Not Exists Product (product_id int, product_name varchar(10))\"], \"database_schema\": {\"Sales\": {\"sale_id\": \"INT\", \"product_id\": \"INT\", \"year\": \"INT\", \"quantity\": \"INT\", \"price\": \"INT\"}, \"Product\": {\"product_id\": \"INT\", \"product_name\": \"VARCHAR(10)\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)",
|
||||
"Create table If Not Exists Product (product_id int, product_name varchar(10))",
|
||||
"Truncate table Sales",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000')",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('2', '100', '2009', '12', '5000')",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('7', '200', '2011', '15', '9000')",
|
||||
"Truncate table Product",
|
||||
"insert into Product (product_id, product_name) values ('100', 'Nokia')",
|
||||
"insert into Product (product_id, product_name) values ('200', 'Apple')",
|
||||
"insert into Product (product_id, product_name) values ('300', 'Samsung')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
99
leetcode/originData/product-sales-analysis-iii.json
Normal file
99
leetcode/originData/product-sales-analysis-iii.json
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1155",
|
||||
"questionFrontendId": "1070",
|
||||
"boundTopicId": null,
|
||||
"title": "Product Sales Analysis III",
|
||||
"titleSlug": "product-sales-analysis-iii",
|
||||
"content": "<p>Table: <code>Sales</code></p>\n\n<pre>\n+-------------+-------+\n| Column Name | Type |\n+-------------+-------+\n| sale_id | int |\n| product_id | int |\n| year | int |\n| quantity | int |\n| price | int |\n+-------------+-------+\n(sale_id, year) is the primary key (combination of columns with unique values) of this table.\nproduct_id is a foreign key (reference column) to <code>Product</code> table.\nEach row of this table shows a sale on the product product_id in a certain year.\nNote that the price is per unit.\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_id | int |\n| product_name | varchar |\n+--------------+---------+\nproduct_id is the primary key (column with unique values) of this table.\nEach row of this table indicates the product name of each product.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to select the <strong>product id</strong>, <strong>year</strong>, <strong>quantity</strong>, and <strong>price</strong> for the <strong>first year</strong> of every product sold.</p>\n\n<p>Return the resulting 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> \nSales table:\n+---------+------------+------+----------+-------+\n| sale_id | product_id | year | quantity | price |\n+---------+------------+------+----------+-------+ \n| 1 | 100 | 2008 | 10 | 5000 |\n| 2 | 100 | 2009 | 12 | 5000 |\n| 7 | 200 | 2011 | 15 | 9000 |\n+---------+------------+------+----------+-------+\nProduct table:\n+------------+--------------+\n| product_id | product_name |\n+------------+--------------+\n| 100 | Nokia |\n| 200 | Apple |\n| 300 | Samsung |\n+------------+--------------+\n<strong>Output:</strong> \n+------------+------------+----------+-------+\n| product_id | first_year | quantity | price |\n+------------+------------+----------+-------+ \n| 100 | 2008 | 10 | 5000 |\n| 200 | 2011 | 15 | 9000 |\n+------------+------------+----------+-------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 290,
|
||||
"dislikes": 737,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Product Sales Analysis II\", \"titleSlug\": \"product-sales-analysis-ii\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Product Sales Analysis IV\", \"titleSlug\": \"product-sales-analysis-iv\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Product Sales Analysis V\", \"titleSlug\": \"product-sales-analysis-v\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Sales\":[\"sale_id\",\"product_id\",\"year\",\"quantity\",\"price\"],\"Product\":[\"product_id\",\"product_name\"]},\"rows\":{\"Sales\":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],\"Product\":[[100,\"Nokia\"],[200,\"Apple\"],[300,\"Samsung\"]]}}",
|
||||
"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 sales_analysis(sales: 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\": \"86.9K\", \"totalSubmission\": \"202.6K\", \"totalAcceptedRaw\": 86898, \"totalSubmissionRaw\": 202639, \"acRate\": \"42.9%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2133",
|
||||
"canSeeDetail": true,
|
||||
"paidOnly": false,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Sales\":[\"sale_id\",\"product_id\",\"year\",\"quantity\",\"price\"],\"Product\":[\"product_id\",\"product_name\"]},\"rows\":{\"Sales\":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],\"Product\":[[100,\"Nokia\"],[200,\"Apple\"],[300,\"Samsung\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table If Not Exists Product (product_id int, product_name varchar(10))\"], \"mssql\": [\"Create table Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table Product (product_id int, product_name varchar(10))\"], \"oraclesql\": [\"Create table Sales (sale_id int, product_id int, year int, quantity int, price int)\", \"Create table Product (product_id int, product_name varchar(10))\"], \"database\": true, \"name\": \"sales_analysis\", \"pythondata\": [\"Sales = pd.DataFrame([], columns=['sale_id', 'product_id', 'year', 'quantity', 'price']).astype({'sale_id':'Int64', 'product_id':'Int64', 'year':'Int64', 'quantity':'Int64', 'price':'Int64'})\", \"Product = pd.DataFrame([], columns=['product_id', 'product_name']).astype({'product_id':'Int64', 'product_name':'object'})\"], \"postgresql\": [\"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)\\n\", \"Create table If Not Exists Product (product_id int, product_name varchar(10))\"], \"database_schema\": {\"Sales\": {\"sale_id\": \"INT\", \"product_id\": \"INT\", \"year\": \"INT\", \"quantity\": \"INT\", \"price\": \"INT\"}, \"Product\": {\"product_id\": \"INT\", \"product_name\": \"VARCHAR(10)\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)",
|
||||
"Create table If Not Exists Product (product_id int, product_name varchar(10))",
|
||||
"Truncate table Sales",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000')",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('2', '100', '2009', '12', '5000')",
|
||||
"insert into Sales (sale_id, product_id, year, quantity, price) values ('7', '200', '2011', '15', '9000')",
|
||||
"Truncate table Product",
|
||||
"insert into Product (product_id, product_name) values ('100', 'Nokia')",
|
||||
"insert into Product (product_id, product_name) values ('200', 'Apple')",
|
||||
"insert into Product (product_id, product_name) values ('300', 'Samsung')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
95
leetcode/originData/project-employees-i.json
Normal file
95
leetcode/originData/project-employees-i.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1161",
|
||||
"questionFrontendId": "1075",
|
||||
"boundTopicId": null,
|
||||
"title": "Project Employees I",
|
||||
"titleSlug": "project-employees-i",
|
||||
"content": "<p>Table: <code>Project</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| project_id | int |\n| employee_id | int |\n+-------------+---------+\n(project_id, employee_id) is the primary key of this table.\nemployee_id is a foreign key to <code>Employee</code> table.\nEach row of this table indicates that the employee with employee_id is working on the project with project_id.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Employee</code></p>\n\n<pre>\n+------------------+---------+\n| Column Name | Type |\n+------------------+---------+\n| employee_id | int |\n| name | varchar |\n| experience_years | int |\n+------------------+---------+\nemployee_id is the primary key of this table. It's guaranteed that experience_years is not NULL.\nEach row of this table contains information about one employee.\n</pre>\n\n<p> </p>\n\n<p>Write an SQL query that reports the <strong>average</strong> experience years of all the employees for each project, <strong>rounded to 2 digits</strong>.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The query 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> \nProject table:\n+-------------+-------------+\n| project_id | employee_id |\n+-------------+-------------+\n| 1 | 1 |\n| 1 | 2 |\n| 1 | 3 |\n| 2 | 1 |\n| 2 | 4 |\n+-------------+-------------+\nEmployee table:\n+-------------+--------+------------------+\n| employee_id | name | experience_years |\n+-------------+--------+------------------+\n| 1 | Khaled | 3 |\n| 2 | Ali | 2 |\n| 3 | John | 1 |\n| 4 | Doe | 2 |\n+-------------+--------+------------------+\n<strong>Output:</strong> \n+-------------+---------------+\n| project_id | average_years |\n+-------------+---------------+\n| 1 | 2.00 |\n| 2 | 2.50 |\n+-------------+---------------+\n<strong>Explanation:</strong> The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and for the second project is (3 + 2) / 2 = 2.50\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 444,
|
||||
"dislikes": 112,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Project Employees II\", \"titleSlug\": \"project-employees-ii\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Project\":[\"project_id\",\"employee_id\"],\"Employee\":[\"employee_id\",\"name\",\"experience_years\"]},\"rows\":{\"Project\":[[1,1],[1,2],[1,3],[2,1],[2,4]],\"Employee\":[[1,\"Khaled\",3],[2,\"Ali\",2],[3,\"John\",1],[4,\"Doe\",2]]}}",
|
||||
"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 project_employees_i(project: pd.DataFrame, employee: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"132.2K\", \"totalSubmission\": \"204.4K\", \"totalAcceptedRaw\": 132212, \"totalSubmissionRaw\": 204382, \"acRate\": \"64.7%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Project\":[\"project_id\",\"employee_id\"],\"Employee\":[\"employee_id\",\"name\",\"experience_years\"]},\"rows\":{\"Project\":[[1,1],[1,2],[1,3],[2,1],[2,4]],\"Employee\":[[1,\"Khaled\",3],[2,\"Ali\",2],[3,\"John\",1],[4,\"Doe\",2]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Project (project_id int, employee_id int)\", \"Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)\"], \"mssql\": [\"Create table Project (project_id int, employee_id int)\", \"Create table Employee (employee_id int, name varchar(10), experience_years int)\"], \"oraclesql\": [\"Create table Project (project_id int, employee_id int)\", \"Create table Employee (employee_id int, name varchar(10), experience_years int)\"], \"database\": true, \"name\": \"project_employees_i\", \"pythondata\": [\"Project = pd.DataFrame([], columns=['project_id', 'employee_id']).astype({'project_id':'Int64', 'employee_id':'Int64'})\", \"Employee = pd.DataFrame([], columns=['employee_id', 'name', 'experience_years']).astype({'employee_id':'Int64', 'name':'object', 'experience_years':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Project (project_id int, employee_id int)\", \"Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)\"], \"database_schema\": {\"Project\": {\"project_id\": \"INT\", \"employee_id\": \"INT\"}, \"Employee\": {\"employee_id\": \"INT\", \"name\": \"VARCHAR(10)\", \"experience_years\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Project (project_id int, employee_id int)",
|
||||
"Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)",
|
||||
"Truncate table Project",
|
||||
"insert into Project (project_id, employee_id) values ('1', '1')",
|
||||
"insert into Project (project_id, employee_id) values ('1', '2')",
|
||||
"insert into Project (project_id, employee_id) values ('1', '3')",
|
||||
"insert into Project (project_id, employee_id) values ('2', '1')",
|
||||
"insert into Project (project_id, employee_id) values ('2', '4')",
|
||||
"Truncate table Employee",
|
||||
"insert into Employee (employee_id, name, experience_years) values ('1', 'Khaled', '3')",
|
||||
"insert into Employee (employee_id, name, experience_years) values ('2', 'Ali', '2')",
|
||||
"insert into Employee (employee_id, name, experience_years) values ('3', 'John', '1')",
|
||||
"insert into Employee (employee_id, name, experience_years) values ('4', 'Doe', '2')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
90
leetcode/originData/queries-quality-and-percentage.json
Normal file
90
leetcode/originData/queries-quality-and-percentage.json
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1338",
|
||||
"questionFrontendId": "1211",
|
||||
"boundTopicId": null,
|
||||
"title": "Queries Quality and Percentage",
|
||||
"titleSlug": "queries-quality-and-percentage",
|
||||
"content": "<p>Table: <code>Queries</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| query_name | varchar |\n| result | varchar |\n| position | int |\n| rating | int |\n+-------------+---------+\nThis table may have duplicate rows.\nThis table contains information collected from some queries on a database.\nThe <code>position</code> column has a value from <strong>1</strong> to <strong>500</strong>.\nThe <code>rating</code> column has a value from <strong>1</strong> to <strong>5</strong>. Query with <code>rating</code> less than 3 is a poor query.\n</pre>\n\n<p> </p>\n\n<p>We define query <code>quality</code> as:</p>\n\n<blockquote>\n<p>The average of the ratio between query rating and its position.</p>\n</blockquote>\n\n<p>We also define <code>poor query percentage</code> as:</p>\n\n<blockquote>\n<p>The percentage of all queries with rating less than 3.</p>\n</blockquote>\n\n<p>Write a solution to find each <code>query_name</code>, the <code>quality</code> and <code>poor_query_percentage</code>.</p>\n\n<p>Both <code>quality</code> and <code>poor_query_percentage</code> should be <strong>rounded to 2 decimal places</strong>.</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> \nQueries table:\n+------------+-------------------+----------+--------+\n| query_name | result | position | rating |\n+------------+-------------------+----------+--------+\n| Dog | Golden Retriever | 1 | 5 |\n| Dog | German Shepherd | 2 | 5 |\n| Dog | Mule | 200 | 1 |\n| Cat | Shirazi | 5 | 2 |\n| Cat | Siamese | 3 | 3 |\n| Cat | Sphynx | 7 | 4 |\n+------------+-------------------+----------+--------+\n<strong>Output:</strong> \n+------------+---------+-----------------------+\n| query_name | quality | poor_query_percentage |\n+------------+---------+-----------------------+\n| Dog | 2.50 | 33.33 |\n| Cat | 0.66 | 33.33 |\n+------------+---------+-----------------------+\n<strong>Explanation:</strong> \nDog queries quality is ((5 / 1) + (5 / 2) + (1 / 200)) / 3 = 2.50\nDog queries poor_ query_percentage is (1 / 3) * 100 = 33.33\n\nCat queries quality equals ((2 / 5) + (3 / 3) + (4 / 7)) / 3 = 0.66\nCat queries poor_ query_percentage is (1 / 3) * 100 = 33.33\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 456,
|
||||
"dislikes": 322,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Percentage of Users Attended a Contest\", \"titleSlug\": \"percentage-of-users-attended-a-contest\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]",
|
||||
"exampleTestcases": "{\"headers\":{\"Queries\":[\"query_name\",\"result\",\"position\",\"rating\"]},\"rows\":{\"Queries\":[[\"Dog\",\"Golden Retriever\",1,5],[\"Dog\",\"German Shepherd\",2,5],[\"Dog\",\"Mule\",200,1],[\"Cat\",\"Shirazi\",5,2],[\"Cat\",\"Siamese\",3,3],[\"Cat\",\"Sphynx\",7,4]]}}",
|
||||
"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 queries_stats(queries: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"99.8K\", \"totalSubmission\": \"161.8K\", \"totalAcceptedRaw\": 99835, \"totalSubmissionRaw\": 161818, \"acRate\": \"61.7%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Queries\":[\"query_name\",\"result\",\"position\",\"rating\"]},\"rows\":{\"Queries\":[[\"Dog\",\"Golden Retriever\",1,5],[\"Dog\",\"German Shepherd\",2,5],[\"Dog\",\"Mule\",200,1],[\"Cat\",\"Shirazi\",5,2],[\"Cat\",\"Siamese\",3,3],[\"Cat\",\"Sphynx\",7,4]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Queries (query_name varchar(30), result varchar(50), position int, rating int)\"], \"mssql\": [\"create table Queries (query_name varchar(30), result varchar(50), position int, rating int)\"], \"oraclesql\": [\"create table Queries (query_name varchar(30), result varchar(50), position int, rating int)\"], \"database\": true, \"name\": \"queries_stats\", \"pythondata\": [\"Queries = pd.DataFrame([], columns=['query_name', 'result', 'position', 'rating']).astype({'query_name':'object', 'result':'object', 'position':'Int64', 'rating':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Queries (query_name varchar(30), result varchar(50), position int, rating int)\"], \"database_schema\": {\"Queries\": {\"query_name\": \"VARCHAR(30)\", \"result\": \"VARCHAR(50)\", \"position\": \"INT\", \"rating\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Queries (query_name varchar(30), result varchar(50), position int, rating int)",
|
||||
"Truncate table Queries",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Dog', 'Golden Retriever', '1', '5')",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Dog', 'German Shepherd', '2', '5')",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Dog', 'Mule', '200', '1')",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Cat', 'Shirazi', '5', '2')",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Cat', 'Siamese', '3', '3')",
|
||||
"insert into Queries (query_name, result, position, rating) values ('Cat', 'Sphynx', '7', '4')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1509",
|
||||
"questionFrontendId": "1378",
|
||||
"boundTopicId": null,
|
||||
"title": "Replace Employee ID With The Unique Identifier",
|
||||
"titleSlug": "replace-employee-id-with-the-unique-identifier",
|
||||
"content": "<p>Table: <code>Employees</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| id | int |\n| name | varchar |\n+---------------+---------+\nid is the primary key (column with unique values) for this table.\nEach row of this table contains the id and the name of an employee in a company.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>EmployeeUNI</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| id | int |\n| unique_id | int |\n+---------------+---------+\n(id, unique_id) is the primary key (combination of columns with unique values) for this table.\nEach row of this table contains the id and the corresponding unique id of an employee in the company.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to show the <strong>unique ID </strong>of each user, If a user does not have a unique ID replace just show <code>null</code>.</p>\n\n<p>Return the result table in <strong>any</strong> order.</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> \nEmployees table:\n+----+----------+\n| id | name |\n+----+----------+\n| 1 | Alice |\n| 7 | Bob |\n| 11 | Meir |\n| 90 | Winston |\n| 3 | Jonathan |\n+----+----------+\nEmployeeUNI table:\n+----+-----------+\n| id | unique_id |\n+----+-----------+\n| 3 | 1 |\n| 11 | 2 |\n| 90 | 3 |\n+----+-----------+\n<strong>Output:</strong> \n+-----------+----------+\n| unique_id | name |\n+-----------+----------+\n| null | Alice |\n| null | Bob |\n| 2 | Meir |\n| 3 | Winston |\n| 1 | Jonathan |\n+-----------+----------+\n<strong>Explanation:</strong> \nAlice and Bob do not have a unique ID, We will show null instead.\nThe unique ID of Meir is 2.\nThe unique ID of Winston is 3.\nThe unique ID of Jonathan is 1.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 827,
|
||||
"dislikes": 85,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Employees\":[\"id\",\"name\"],\"EmployeeUNI\":[\"id\",\"unique_id\"]},\"rows\":{\"Employees\":[[1,\"Alice\"],[7,\"Bob\"],[11,\"Meir\"],[90,\"Winston\"],[3,\"Jonathan\"]],\"EmployeeUNI\":[[3,1],[11,2],[90,3]]}}",
|
||||
"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 replace_employee_id(employees: pd.DataFrame, employee_uni: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"222.4K\", \"totalSubmission\": \"269.2K\", \"totalAcceptedRaw\": 222440, \"totalSubmissionRaw\": 269242, \"acRate\": \"82.6%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2017",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Employees\":[\"id\",\"name\"],\"EmployeeUNI\":[\"id\",\"unique_id\"]},\"rows\":{\"Employees\":[[1,\"Alice\"],[7,\"Bob\"],[11,\"Meir\"],[90,\"Winston\"],[3,\"Jonathan\"]],\"EmployeeUNI\":[[3,1],[11,2],[90,3]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employees (id int, name varchar(20))\", \"Create table If Not Exists EmployeeUNI (id int, unique_id int)\"], \"mssql\": [\"Create table Employees (id int, name varchar(20))\", \"Create table EmployeeUNI (id int, unique_id int)\"], \"oraclesql\": [\"Create table Employees (id int, name varchar(20))\", \"Create table EmployeeUNI (id int, unique_id int)\"], \"database\": true, \"name\": \"replace_employee_id\", \"pythondata\": [\"Employees = pd.DataFrame([], columns=['id', 'name']).astype({'id':'int64', 'name':'object'})\", \"EmployeeUNI = pd.DataFrame([], columns=['id', 'unique_id']).astype({'id':'int64', 'unique_id':'int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Employees (id int, name varchar(20))\\n\", \"Create table If Not Exists EmployeeUNI (id int, unique_id int)\"], \"database_schema\": {\"Employees\": {\"id\": \"INT\", \"name\": \"VARCHAR(20)\"}, \"EmployeeUNI\": {\"id\": \"INT\", \"unique_id\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employees (id int, name varchar(20))",
|
||||
"Create table If Not Exists EmployeeUNI (id int, unique_id int)",
|
||||
"Truncate table Employees",
|
||||
"insert into Employees (id, name) values ('1', 'Alice')",
|
||||
"insert into Employees (id, name) values ('7', 'Bob')",
|
||||
"insert into Employees (id, name) values ('11', 'Meir')",
|
||||
"insert into Employees (id, name) values ('90', 'Winston')",
|
||||
"insert into Employees (id, name) values ('3', 'Jonathan')",
|
||||
"Truncate table EmployeeUNI",
|
||||
"insert into EmployeeUNI (id, unique_id) values ('3', '1')",
|
||||
"insert into EmployeeUNI (id, unique_id) values ('11', '2')",
|
||||
"insert into EmployeeUNI (id, unique_id) values ('90', '3')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
95
leetcode/originData/restaurant-growth.json
Normal file
95
leetcode/originData/restaurant-growth.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1452",
|
||||
"questionFrontendId": "1321",
|
||||
"boundTopicId": null,
|
||||
"title": "Restaurant Growth",
|
||||
"titleSlug": "restaurant-growth",
|
||||
"content": "<p>Table: <code>Customer</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| customer_id | int |\n| name | varchar |\n| visited_on | date |\n| amount | int |\n+---------------+---------+\nIn SQL,(customer_id, visited_on) is the primary key for this table.\nThis table contains data about customer transactions in a restaurant.\nvisited_on is the date on which the customer with ID (customer_id) has visited the restaurant.\namount is the total paid by a customer.\n</pre>\n\n<p> </p>\n\n<p>You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day).</p>\n\n<p>Compute the moving average of how much the customer paid in a seven days window (i.e., current day + 6 days before). <code>average_amount</code> should be <strong>rounded to two decimal places</strong>.</p>\n\n<p>Return the result table ordered by <code>visited_on</code> <strong>in ascending 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 | name | visited_on | amount |\n+-------------+--------------+--------------+-------------+\n| 1 | Jhon | 2019-01-01 | 100 |\n| 2 | Daniel | 2019-01-02 | 110 |\n| 3 | Jade | 2019-01-03 | 120 |\n| 4 | Khaled | 2019-01-04 | 130 |\n| 5 | Winston | 2019-01-05 | 110 | \n| 6 | Elvis | 2019-01-06 | 140 | \n| 7 | Anna | 2019-01-07 | 150 |\n| 8 | Maria | 2019-01-08 | 80 |\n| 9 | Jaze | 2019-01-09 | 110 | \n| 1 | Jhon | 2019-01-10 | 130 | \n| 3 | Jade | 2019-01-10 | 150 | \n+-------------+--------------+--------------+-------------+\n<strong>Output:</strong> \n+--------------+--------------+----------------+\n| visited_on | amount | average_amount |\n+--------------+--------------+----------------+\n| 2019-01-07 | 860 | 122.86 |\n| 2019-01-08 | 840 | 120 |\n| 2019-01-09 | 840 | 120 |\n| 2019-01-10 | 1000 | 142.86 |\n+--------------+--------------+----------------+\n<strong>Explanation:</strong> \n1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86\n2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120\n3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120\n4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 629,
|
||||
"dislikes": 225,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Customer\":[\"customer_id\",\"name\",\"visited_on\",\"amount\"]},\"rows\":{\"Customer\":[[1,\"Jhon\",\"2019-01-01\",100],[2,\"Daniel\",\"2019-01-02\",110],[3,\"Jade\",\"2019-01-03\",120],[4,\"Khaled\",\"2019-01-04\",130],[5,\"Winston\",\"2019-01-05\",110],[6,\"Elvis\",\"2019-01-06\",140],[7,\"Anna\",\"2019-01-07\",150],[8,\"Maria\",\"2019-01-08\",80],[9,\"Jaze\",\"2019-01-09\",110],[1,\"Jhon\",\"2019-01-10\",130],[3,\"Jade\",\"2019-01-10\",150]]}}",
|
||||
"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 restaurant_growth(customer: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"54.9K\", \"totalSubmission\": \"114.2K\", \"totalAcceptedRaw\": 54858, \"totalSubmissionRaw\": 114223, \"acRate\": \"48.0%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Customer\":[\"customer_id\",\"name\",\"visited_on\",\"amount\"]},\"rows\":{\"Customer\":[[1,\"Jhon\",\"2019-01-01\",100],[2,\"Daniel\",\"2019-01-02\",110],[3,\"Jade\",\"2019-01-03\",120],[4,\"Khaled\",\"2019-01-04\",130],[5,\"Winston\",\"2019-01-05\",110],[6,\"Elvis\",\"2019-01-06\",140],[7,\"Anna\",\"2019-01-07\",150],[8,\"Maria\",\"2019-01-08\",80],[9,\"Jaze\",\"2019-01-09\",110],[1,\"Jhon\",\"2019-01-10\",130],[3,\"Jade\",\"2019-01-10\",150]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Customer (customer_id int, name varchar(20), visited_on date, amount int)\"], \"mssql\": [\"Create table Customer (customer_id int, name varchar(20), visited_on date, amount int)\"], \"oraclesql\": [\"Create table Customer (customer_id int, name varchar(20), visited_on date, amount int)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"restaurant_growth\", \"pythondata\": [\"Customer = pd.DataFrame([], columns=['customer_id', 'name', 'visited_on', 'amount']).astype({'customer_id':'Int64', 'name':'object', 'visited_on':'datetime64[ns]', 'amount':'Int64'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Customer (customer_id int, name varchar(20), visited_on date, amount int)\"], \"database_schema\": {\"Customer\": {\"customer_id\": \"INT\", \"name\": \"VARCHAR(20)\", \"visited_on\": \"DATE\", \"amount\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Customer (customer_id int, name varchar(20), visited_on date, amount int)",
|
||||
"Truncate table Customer",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('1', 'Jhon', '2019-01-01', '100')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('2', 'Daniel', '2019-01-02', '110')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('3', 'Jade', '2019-01-03', '120')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('4', 'Khaled', '2019-01-04', '130')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('5', 'Winston', '2019-01-05', '110')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('6', 'Elvis', '2019-01-06', '140')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('7', 'Anna', '2019-01-07', '150')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('8', 'Maria', '2019-01-08', '80')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('9', 'Jaze', '2019-01-09', '110')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('1', 'Jhon', '2019-01-10', '130')",
|
||||
"insert into Customer (customer_id, name, visited_on, amount) values ('3', 'Jade', '2019-01-10', '150')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
113
leetcode/originData/students-and-examinations.json
Normal file
113
leetcode/originData/students-and-examinations.json
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1415",
|
||||
"questionFrontendId": "1280",
|
||||
"boundTopicId": null,
|
||||
"title": "Students and Examinations",
|
||||
"titleSlug": "students-and-examinations",
|
||||
"content": "<p>Table: <code>Students</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| student_id | int |\n| student_name | varchar |\n+---------------+---------+\nstudent_id is the primary key (column with unique values) for this table.\nEach row of this table contains the ID and the name of one student in the school.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Subjects</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| subject_name | varchar |\n+--------------+---------+\nsubject_name is the primary key (column with unique values) for this table.\nEach row of this table contains the name of one subject in the school.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Examinations</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| student_id | int |\n| subject_name | varchar |\n+--------------+---------+\nThere is no primary key (column with unique values) for this table. It may contain duplicates.\nEach student from the Students table takes every course from the Subjects table.\nEach row of this table indicates that a student with ID student_id attended the exam of subject_name.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the number of times each student attended each exam.</p>\n\n<p>Return the result table ordered by <code>student_id</code> and <code>subject_name</code>.</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> \nStudents table:\n+------------+--------------+\n| student_id | student_name |\n+------------+--------------+\n| 1 | Alice |\n| 2 | Bob |\n| 13 | John |\n| 6 | Alex |\n+------------+--------------+\nSubjects table:\n+--------------+\n| subject_name |\n+--------------+\n| Math |\n| Physics |\n| Programming |\n+--------------+\nExaminations table:\n+------------+--------------+\n| student_id | subject_name |\n+------------+--------------+\n| 1 | Math |\n| 1 | Physics |\n| 1 | Programming |\n| 2 | Programming |\n| 1 | Physics |\n| 1 | Math |\n| 13 | Math |\n| 13 | Programming |\n| 13 | Physics |\n| 2 | Math |\n| 1 | Math |\n+------------+--------------+\n<strong>Output:</strong> \n+------------+--------------+--------------+----------------+\n| student_id | student_name | subject_name | attended_exams |\n+------------+--------------+--------------+----------------+\n| 1 | Alice | Math | 3 |\n| 1 | Alice | Physics | 2 |\n| 1 | Alice | Programming | 1 |\n| 2 | Bob | Math | 1 |\n| 2 | Bob | Physics | 0 |\n| 2 | Bob | Programming | 1 |\n| 6 | Alex | Math | 0 |\n| 6 | Alex | Physics | 0 |\n| 6 | Alex | Programming | 0 |\n| 13 | John | Math | 1 |\n| 13 | John | Physics | 1 |\n| 13 | John | Programming | 1 |\n+------------+--------------+--------------+----------------+\n<strong>Explanation:</strong> \nThe result table should contain all students and all subjects.\nAlice attended the Math exam 3 times, the Physics exam 2 times, and the Programming exam 1 time.\nBob attended the Math exam 1 time, the Programming exam 1 time, and did not attend the Physics exam.\nAlex did not attend any exams.\nJohn attended the Math exam 1 time, the Physics exam 1 time, and the Programming exam 1 time.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 1236,
|
||||
"dislikes": 160,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Students\":[\"student_id\",\"student_name\"],\"Subjects\":[\"subject_name\"],\"Examinations\":[\"student_id\",\"subject_name\"]},\"rows\":{\"Students\":[[1,\"Alice\"],[2,\"Bob\"],[13,\"John\"],[6,\"Alex\"]],\"Subjects\":[[\"Math\"],[\"Physics\"],[\"Programming\"]],\"Examinations\":[[1,\"Math\"],[1,\"Physics\"],[1,\"Programming\"],[2,\"Programming\"],[1,\"Physics\"],[1,\"Math\"],[13,\"Math\"],[13,\"Programming\"],[13,\"Physics\"],[2,\"Math\"],[1,\"Math\"]]}}",
|
||||
"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 students_and_examinations(students: pd.DataFrame, subjects: pd.DataFrame, examinations: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"129.8K\", \"totalSubmission\": \"230.8K\", \"totalAcceptedRaw\": 129823, \"totalSubmissionRaw\": 230750, \"acRate\": \"56.3%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "2018",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Students\":[\"student_id\",\"student_name\"],\"Subjects\":[\"subject_name\"],\"Examinations\":[\"student_id\",\"subject_name\"]},\"rows\":{\"Students\":[[1,\"Alice\"],[2,\"Bob\"],[13,\"John\"],[6,\"Alex\"]],\"Subjects\":[[\"Math\"],[\"Physics\"],[\"Programming\"]],\"Examinations\":[[1,\"Math\"],[1,\"Physics\"],[1,\"Programming\"],[2,\"Programming\"],[1,\"Physics\"],[1,\"Math\"],[13,\"Math\"],[13,\"Programming\"],[13,\"Physics\"],[2,\"Math\"],[1,\"Math\"]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Students (student_id int, student_name varchar(20))\", \"Create table If Not Exists Subjects (subject_name varchar(20))\", \"Create table If Not Exists Examinations (student_id int, subject_name varchar(20))\"], \"mssql\": [\"Create table Students (student_id int, student_name varchar(20))\", \"Create table Subjects (subject_name varchar(20))\", \"Create table Examinations (student_id int, subject_name varchar(20))\"], \"oraclesql\": [\"Create table Students (student_id int, student_name varchar(20))\\n\", \"Create table Subjects (subject_name varchar(20))\\n\", \"Create table Examinations (student_id int, subject_name varchar(20))\"], \"database\": true, \"name\": \"students_and_examinations\", \"pythondata\": [\"Students = pd.DataFrame([], columns=['student_id', 'student_name']).astype({'student_id':'Int64', 'student_name':'object'})\", \"Subjects = pd.DataFrame([], columns=['subject_name']).astype({'subject_name':'object'})\", \"Examinations = pd.DataFrame([], columns=['student_id', 'subject_name']).astype({'student_id':'Int64', 'subject_name':'object'})\"], \"manual\": false, \"postgresql\": [\"\\nCreate table If Not Exists Students (student_id int, student_name varchar(20))\\n\", \"Create table If Not Exists Subjects (subject_name varchar(20))\", \"Create table If Not Exists Examinations (student_id int, subject_name varchar(20))\"], \"database_schema\": {\"Students\": {\"student_id\": \"INT\", \"student_name\": \"VARCHAR(20)\"}, \"Subjects\": {\"subject_name\": \"VARCHAR(20)\"}, \"Examinations\": {\"student_id\": \"INT\", \"subject_name\": \"VARCHAR(20)\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Students (student_id int, student_name varchar(20))",
|
||||
"Create table If Not Exists Subjects (subject_name varchar(20))",
|
||||
"Create table If Not Exists Examinations (student_id int, subject_name varchar(20))",
|
||||
"Truncate table Students",
|
||||
"insert into Students (student_id, student_name) values ('1', 'Alice')",
|
||||
"insert into Students (student_id, student_name) values ('2', 'Bob')",
|
||||
"insert into Students (student_id, student_name) values ('13', 'John')",
|
||||
"insert into Students (student_id, student_name) values ('6', 'Alex')",
|
||||
"Truncate table Subjects",
|
||||
"insert into Subjects (subject_name) values ('Math')",
|
||||
"insert into Subjects (subject_name) values ('Physics')",
|
||||
"insert into Subjects (subject_name) values ('Programming')",
|
||||
"Truncate table Examinations",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Math')",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Physics')",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Programming')",
|
||||
"insert into Examinations (student_id, subject_name) values ('2', 'Programming')",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Physics')",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Math')",
|
||||
"insert into Examinations (student_id, subject_name) values ('13', 'Math')",
|
||||
"insert into Examinations (student_id, subject_name) values ('13', 'Programming')",
|
||||
"insert into Examinations (student_id, subject_name) values ('13', 'Physics')",
|
||||
"insert into Examinations (student_id, subject_name) values ('2', 'Math')",
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Math')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "1882",
|
||||
"questionFrontendId": "1731",
|
||||
"boundTopicId": null,
|
||||
"title": "The Number of Employees Which Report to Each Employee",
|
||||
"titleSlug": "the-number-of-employees-which-report-to-each-employee",
|
||||
"content": "<p>Table: <code>Employees</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| employee_id | int |\n| name | varchar |\n| reports_to | int |\n| age | int |\n+-------------+----------+\nemployee_id is the column with unique values for this table.\nThis table contains information about the employees and the id of the manager they report to. Some employees do not report to anyone (reports_to is null). \n</pre>\n\n<p> </p>\n\n<p>For this problem, we will consider a <strong>manager</strong> an employee who has at least 1 other employee reporting to them.</p>\n\n<p>Write a solution to report the ids and the names of all <strong>managers</strong>, the number of employees who report <strong>directly</strong> to them, and the average age of the reports rounded to the nearest integer.</p>\n\n<p>Return the result table ordered by <code>employee_id</code>.</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> \nEmployees table:\n+-------------+---------+------------+-----+\n| employee_id | name | reports_to | age |\n+-------------+---------+------------+-----+\n| 9 | Hercy | null | 43 |\n| 6 | Alice | 9 | 41 |\n| 4 | Bob | 9 | 36 |\n| 2 | Winston | null | 37 |\n+-------------+---------+------------+-----+\n<strong>Output:</strong> \n+-------------+-------+---------------+-------------+\n| employee_id | name | reports_count | average_age |\n+-------------+-------+---------------+-------------+\n| 9 | Hercy | 2 | 39 |\n+-------------+-------+---------------+-------------+\n<strong>Explanation:</strong> Hercy has 2 people report directly to him, Alice and Bob. Their average age is (41+36)/2 = 38.5, which is 39 after rounding it to the nearest integer.\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 374,
|
||||
"dislikes": 52,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Employees\":[\"employee_id\",\"name\",\"reports_to\",\"age\"]},\"rows\":{\"Employees\":[[9,\"Hercy\",null,43],[6,\"Alice\",9,41],[4,\"Bob\",9,36],[2,\"Winston\",null,37]]}}",
|
||||
"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 count_employees(employees: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"65K\", \"totalSubmission\": \"145.1K\", \"totalAcceptedRaw\": 65040, \"totalSubmissionRaw\": 145130, \"acRate\": \"44.8%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Employees\":[\"employee_id\",\"name\",\"reports_to\",\"age\"]},\"rows\":{\"Employees\":[[9,\"Hercy\",null,43],[6,\"Alice\",9,41],[4,\"Bob\",9,36],[2,\"Winston\",null,37]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Employees(employee_id int, name varchar(20), reports_to int, age int)\"], \"mssql\": [\"Create table Employees(employee_id int, name varchar(20), reports_to int, age int)\"], \"oraclesql\": [\"Create table Employees(employee_id int, name varchar(20), reports_to int, age int)\"], \"database\": true, \"name\": \"count_employees\", \"pythondata\": [\"Employees = pd.DataFrame([], columns=['employee_id', 'name', 'reports_to', 'age']).astype({'employee_id':'Int64', 'name':'object', 'reports_to':'Int64', 'age':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Employees(employee_id int, name varchar(20), reports_to int, age int)\"], \"database_schema\": {\"Employees\": {\"employee_id\": \"INT\", \"name\": \"VARCHAR(20)\", \"reports_to\": \"INT\", \"age\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Employees(employee_id int, name varchar(20), reports_to int, age int)",
|
||||
"Truncate table Employees",
|
||||
"insert into Employees (employee_id, name, reports_to, age) values ('9', 'Hercy', 'None', '43')",
|
||||
"insert into Employees (employee_id, name, reports_to, age) values ('6', 'Alice', '9', '41')",
|
||||
"insert into Employees (employee_id, name, reports_to, age) values ('4', 'Bob', '9', '36')",
|
||||
"insert into Employees (employee_id, name, reports_to, age) values ('2', 'Winston', 'None', '37')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
93
leetcode/originData/triangle-judgement.json
Normal file
93
leetcode/originData/triangle-judgement.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "610",
|
||||
"questionFrontendId": "610",
|
||||
"boundTopicId": null,
|
||||
"title": "Triangle Judgement",
|
||||
"titleSlug": "triangle-judgement",
|
||||
"content": "<p>Table: <code>Triangle</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| x | int |\n| y | int |\n| z | int |\n+-------------+------+\nIn SQL, (x, y, z) is the primary key column for this table.\nEach row of this table contains the lengths of three line segments.\n</pre>\n\n<p> </p>\n\n<p>Report for every three line segments whether they can form a triangle.</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> \nTriangle table:\n+----+----+----+\n| x | y | z |\n+----+----+----+\n| 13 | 15 | 30 |\n| 10 | 20 | 15 |\n+----+----+----+\n<strong>Output:</strong> \n+----+----+----+----------+\n| x | y | z | triangle |\n+----+----+----+----------+\n| 13 | 15 | 30 | No |\n| 10 | 20 | 15 | Yes |\n+----+----+----+----------+\n</pre>\n",
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 497,
|
||||
"dislikes": 129,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": "{\"headers\":{\"Triangle\":[\"x\",\"y\",\"z\"]},\"rows\":{\"Triangle\":[[13,15,30],[10,20,15]]}}",
|
||||
"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 triangle_judgement(triangle: pd.DataFrame) -> pd.DataFrame:\n ",
|
||||
"__typename": "CodeSnippetNode"
|
||||
},
|
||||
{
|
||||
"lang": "PostgreSQL",
|
||||
"langSlug": "postgresql",
|
||||
"code": "-- Write your PostgreSQL query statement below\n",
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"119.6K\", \"totalSubmission\": \"169.5K\", \"totalAcceptedRaw\": 119604, \"totalSubmissionRaw\": 169454, \"acRate\": \"70.6%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "180",
|
||||
"canSeeDetail": false,
|
||||
"paidOnly": true,
|
||||
"hasVideoSolution": false,
|
||||
"paidOnlyVideo": true,
|
||||
"__typename": "ArticleNode"
|
||||
},
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Triangle\":[\"x\",\"y\",\"z\"]},\"rows\":{\"Triangle\":[[13,15,30],[10,20,15]]}}",
|
||||
"metaData": "{\"mysql\": [\"Create table If Not Exists Triangle (x int, y int, z int)\"], \"mssql\": [\"Create table Triangle (x int, y int, z int)\"], \"oraclesql\": [\"Create table Triangle (x int, y int, z int)\"], \"database\": true, \"name\": \"triangle_judgement\", \"pythondata\": [\"Triangle = pd.DataFrame([], columns=['x', 'y', 'z']).astype({'x':'Int64', 'y':'Int64', 'z':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Triangle (x int, y int, z int)\"], \"database_schema\": {\"Triangle\": {\"x\": \"INT\", \"y\": \"INT\", \"z\": \"INT\"}}}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Triangle (x int, y int, z int)",
|
||||
"Truncate table Triangle",
|
||||
"insert into Triangle (x, y, z) values ('13', '15', '30')",
|
||||
"insert into Triangle (x, y, z) values ('10', '20', '15')"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user