1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

Compare commits

...

2 Commits

Author SHA1 Message Date
29fc260318 update 2023-10-05 03:40:53 +08:00
96286caf59 update 2023-10-05 03:40:12 +08:00
93 changed files with 21179 additions and 13480 deletions

View File

@ -1,6 +1,6 @@
# 力扣题库(完整版)
> 最后更新日期: **2023.09.24**
> 最后更新日期: **2023.10.05**
>
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
{
"data": {
"question": {
"questionId": "3160",
"questionFrontendId": "2893",
"categoryTitle": "Database",
"boundTopicId": 2468419,
"title": "Calculate Orders Within Each Interval",
"titleSlug": "calculate-orders-within-each-interval",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"0\", \"totalSubmission\": \"0\", \"totalAcceptedRaw\": 0, \"totalSubmissionRaw\": 0, \"acRate\": \"N/A\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Orders\": [\"minute\", \"order_count\"]}, \"rows\": {\"Orders\":[[1,0],[2,2],[3,4],[4,6],[5,1],[6,4],[7,1],[8,2],[9,4],[10,1],[11,4],[12,6]]}}",
"metaData": "{\"mysql\":[\"Create table if not exists Orders(minute int, order_count int)\"],\"mssql\":[\"Create table Orders(minute int, order_count int)\"],\"oraclesql\":[\"Create table Orders(minute int, order_count int)\"],\"database\":true,\"name\":\"calculate_runs\",\"languages\":[\"mysql\",\"mssql\",\"oraclesql\"],\"database_schema\":{\"Orders\":{\"minute\":\"INT\",\"order_count\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists Orders(minute int, order_count int)",
"Truncate table Orders",
"insert into Orders (minute, order_count) values ('1', '0')",
"insert into Orders (minute, order_count) values ('2', '2')",
"insert into Orders (minute, order_count) values ('3', '4')",
"insert into Orders (minute, order_count) values ('4', '6')",
"insert into Orders (minute, order_count) values ('5', '1')",
"insert into Orders (minute, order_count) values ('6', '4')",
"insert into Orders (minute, order_count) values ('7', '1')",
"insert into Orders (minute, order_count) values ('8', '2')",
"insert into Orders (minute, order_count) values ('9', '4')",
"insert into Orders (minute, order_count) values ('10', '1')",
"insert into Orders (minute, order_count) values ('11', '4')",
"insert into Orders (minute, order_count) values ('12', '6')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\": {\"Orders\": [\"minute\", \"order_count\"]}, \"rows\": {\"Orders\":[[1,0],[2,2],[3,4],[4,6],[5,1],[6,4],[7,1],[8,2],[9,4],[10,1],[11,4],[12,6]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3069",
"questionFrontendId": "2886",
"categoryTitle": "Algorithms",
"boundTopicId": 2467490,
"title": "Change Data Type",
"titleSlug": "change-data-type",
"content": "<pre>\nDataFrame <code>students</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n| grade | float |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to correct the errors:</p>\n\n<p>The <code>grade</code> column is stored as floats,&nbsp;convert it to integers.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:\n</strong>DataFrame students:\n+------------+------+-----+-------+\n| student_id | name | age | grade |\n+------------+------+-----+-------+\n| 1 | Ava | 6 | 73.0 |\n| 2 | Kate | 15 | 87.0 |\n+------------+------+-----+-------+\n<strong>Output:\n</strong>+------------+------+-----+-------+\n| student_id | name | age | grade |\n+------------+------+-----+-------+\n| 1 | Ava | 6 | 73 |\n| 2 | Kate | 15 | 87 |\n+------------+------+-----+-------+\n<strong>Explanation:</strong> \nThe data types of the column grade is converted to int.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef changeDatatype(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11\", \"totalSubmission\": \"11\", \"totalAcceptedRaw\": 11, \"totalSubmissionRaw\": 11, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a build-in function in pandas library with a dictionary to convert the datatype of columns as specified."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\",\"grade\"]},\"rows\":{\"students\":[[1,\"Ava\",6,73.0],[2,\"Kate\",15,87.0]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age', 'grade']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64', 'grade':'Float64'})\"\n ],\n \"database\": true,\n \"name\": \"changeDatatype\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\",\"grade\"]},\"rows\":{\"students\":[[1,\"Ava\",6,73.0],[2,\"Kate\",15,87.0]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3062",
"questionFrontendId": "2877",
"categoryTitle": "Algorithms",
"boundTopicId": 2467481,
"title": "Create a DataFrame from List",
"titleSlug": "create-a-dataframe-from-list",
"content": "<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>\n\n<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>student_data:<strong>\n</strong><code>[\n [1, 15],\n [2, 11],\n [3, 11],\n [4, 20]\n]</code>\n<strong>Output:</strong>\n+------------+-----+\n| student_id | age |\n+------------+-----+\n| 1 | 15 |\n| 2 | 11 |\n| 3 | 11 |\n| 4 | 20 |\n+------------+-----+\n<strong>Explanation:</strong>\nA DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef createDataframe(student_data: List[List[int]]) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"17\", \"totalSubmission\": \"17\", \"totalAcceptedRaw\": 17, \"totalSubmissionRaw\": 17, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a built-in function in pandas library and specifying the column names within it."
],
"solution": null,
"status": null,
"sampleTestCase": "[[1,15],[2,11],[3,11],[4,20]]",
"metaData": "{\n \"name\": \"create_a_dataframe\",\n \"params\": [\n {\n \"name\": \"student_data\",\n \"type\": \"list<list<integer>>\"\n }\n ],\n \"return\": {\n \"type\": \"DataFrame\"\n },\n \"data\": true,\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[[1,15],[2,11],[3,11],[4,20]]",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3066",
"questionFrontendId": "100007",
"categoryTitle": "Algorithms",
"boundTopicId": 2394353,
"title": "Create a New Column",
"titleSlug": "create-a-new-column",
"content": "<pre>\nDataFrame <code>employees</code>\n+-------------+--------+\n| Column Name | Type. |\n+-------------+--------+\n| name | object |\n| salary | int. |\n+-------------+--------+\n</pre>\n\n<p>A&nbsp;company plans to provide its employees with a bonus.</p>\n\n<p>Write a solution to create a new column name <code>bonus</code> that contains the <strong>doubled values</strong> of the <code>salary</code> column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong>\nDataFrame employees\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Piper | 4548 |\n| Grace | 28150 |\n| Georgia | 1103 |\n| Willow | 6593 |\n| Finn | 74576 |\n| Thomas | 24433 |\n+---------+--------+\n<strong>Output:</strong>\n+---------+--------+--------+\n| name | salary | bonus |\n+---------+--------+--------+\n| Piper | 4548 | 9096 |\n| Grace | 28150 | 56300 |\n| Georgia | 1103 | 2206 |\n| Willow | 593 | 13186 |\n| Finn | 74576 | 149152 |\n| Thomas | 24433 | 48866 |\n+---------+--------+--------+\n<strong>Explanation:</strong> \nA new column bonus is created by doubling the value in the column salary.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef createBonusColumn(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"12\", \"totalSubmission\": \"13\", \"totalAcceptedRaw\": 12, \"totalSubmissionRaw\": 13, \"acRate\": \"92.3%\"}",
"hints": [
"Consider using the `[]` brackets with the new column name at the left side of the assignment. The calculation of the value is done element-wise."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Piper\",4548],[\"Grace\",28150],[\"Georgia\",1103],[\"Willow\",6593],[\"Finn\",74576],[\"Thomas\",24433]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['name', 'salary']).astype({'name':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"createBonusColumn\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Piper\",4548],[\"Grace\",28150],[\"Georgia\",1103],[\"Willow\",6593],[\"Finn\",74576],[\"Thomas\",24433]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3065",
"questionFrontendId": "2879",
"categoryTitle": "Algorithms",
"boundTopicId": 2467489,
"title": "Display the First Three Rows",
"titleSlug": "display-the-first-three-rows",
"content": "<pre>\nDataFrame: <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| employee_id | int |\n| name | object |\n| department | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>DataFrame employees\n+-------------+-----------+-----------------------+--------+\n| employee_id | name | department | salary |\n+-------------+-----------+-----------------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n| 60 | Annabelle | InformationTechnology | 37678 |\n| 49 | Jonathan | HumanResources | 23793 |\n| 43 | Khaled | Administration | 40454 |\n+-------------+-----------+-----------------------+--------+\n<strong>Output:</strong>\n+-------------+---------+-------------+--------+\n| employee_id | name | department | salary |\n+-------------+---------+-------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n+-------------+---------+-------------+--------+\n<strong>Explanation:</strong> \nOnly the first 3 rows are displayed.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"18\", \"totalSubmission\": \"18\", \"totalAcceptedRaw\": 18, \"totalSubmissionRaw\": 18, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a built-in function in pandas library to retrieve the initial rows."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['employee_id', 'name', 'department', 'salary']).astype({'employee_id':'Int64', 'name':'object', 'department':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"selectFirstRows\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3071",
"questionFrontendId": "100012",
"categoryTitle": "Algorithms",
"boundTopicId": 2467488,
"title": "Drop Duplicate Rows",
"titleSlug": "drop-duplicate-rows",
"content": "<pre>\nDataFrame customers\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| customer_id | int |\n| name | object |\n| email | object |\n+-------------+--------+\n</pre>\n\n<p>There are some duplicate rows in the DataFrame based on the <code>email</code> column.</p>\n\n<p>Write a solution to remove these duplicate rows and keep only the <strong>first</strong> occurrence.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>\n+-------------+---------+---------------------+\n| customer_id | name | email |\n+-------------+---------+---------------------+\n| 1 | Ella | emily@example.com |\n| 2 | David | michael@example.com |\n| 3 | Zachary | sarah@example.com |\n| 4 | Alice | john@example.com |\n| 5 | Finn | john@example.com |\n| 6 | Violet | alice@example.com |\n+-------------+---------+---------------------+\n<strong>Output: </strong> \n+-------------+---------+---------------------+\n| customer_id | name | email |\n+-------------+---------+---------------------+\n| 1 | Ella | emily@example.com |\n| 2 | David | michael@example.com |\n| 3 | Zachary | sarah@example.com |\n| 4 | Alice | john@example.com |\n| 6 | Violet | alice@example.com |\n+-------------+---------+---------------------+\n<strong>Explanation:</strong>\nAlic (customer_id = 4) and Finn (customer_id = 5) both use john@example.com, so only the first occurrence of this email is retained.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef dropDuplicateEmails(customers: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"13\", \"totalSubmission\": \"13\", \"totalAcceptedRaw\": 13, \"totalSubmissionRaw\": 13, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a build-in function in pandas library to remove the duplicate rows based on specified data."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"customers\":[\"customer_id\",\"name\",\"email\"]},\"rows\":{\"customers\":[[1,\"Ella\",\"emily@example.com\"],[2,\"David\",\"michael@example.com\"],[3,\"Zachary\",\"sarah@example.com\"],[4,\"Alice\",\"john@example.com\"],[5,\"Finn\",\"john@example.com\"],[6,\"Violet\",\"alice@example.com\"]]}}",
"metaData": "{\n \"pythondata\": [\n \"customers = pd.DataFrame([], columns=['customer_id', 'name', 'email']).astype({'customer_id':'Int64', 'name':'object', 'email':'object'})\"\n ],\n \"database\": true,\n \"name\": \"dropDuplicateEmails\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"customers\":[\"customer_id\",\"name\",\"email\"]},\"rows\":{\"customers\":[[1,\"Ella\",\"emily@example.com\"],[2,\"David\",\"michael@example.com\"],[3,\"Zachary\",\"sarah@example.com\"],[4,\"Alice\",\"john@example.com\"],[5,\"Finn\",\"john@example.com\"],[6,\"Violet\",\"alice@example.com\"]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3075",
"questionFrontendId": "100016",
"categoryTitle": "Algorithms",
"boundTopicId": 2467491,
"title": "Drop Missing Data",
"titleSlug": "drop-missing-data",
"content": "<pre>\nDataFrame students\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n</pre>\n\n<p>There are some rows having missing values in the <code>name</code> column.</p>\n\n<p>Write a solution to remove the rows with missing values.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+------------+-------+-----+\n| student_id | name | age |\n+------------+-------+-----+\n| 32 | Piper | 5 |\n| 217 | Grace | 19 |\n| 779 | None | 20 |\n| 849 | None | 14 |\n+------------+-------+-----+\n<strong>Output:\n</strong>+------------+-------+-----+\n| student_id | name | age |\n+------------+-------+-----+\n| 32 | Piper | 5 |\n| 217 | Grace | 19 |\n+------------+-------+-----+\n<strong>Explanation:</strong> \nStudents with ids 779 and 849 have empty values in the name column, so they will be removed.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef dropMissingData(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"14\", \"totalSubmission\": \"14\", \"totalAcceptedRaw\": 14, \"totalSubmissionRaw\": 14, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a build-in function in pandas library to remove the rows with missing values based on specified data."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[32,\"Piper\",5],[217,\"Grace\",19],[779,null,20],[849,null,14]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"dropMissingData\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[32,\"Piper\",5],[217,\"Grace\",19],[779,null,20],[849,null,14]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3070",
"questionFrontendId": "2887",
"categoryTitle": "Algorithms",
"boundTopicId": 2467496,
"title": "Fill Missing Data",
"titleSlug": "fill-missing-data",
"content": "<pre>\nDataFrame <code>products</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| quantity | int |\n| price | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to fill in the missing value as <code><strong>0</strong></code> in the <code>quantity</code> column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | 32 | 135 |\n| WirelessEarbuds | None | 821 |\n| GolfClubs | None | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\n<strong>Output:\n</strong>+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | 32 | 135 |\n| WirelessEarbuds | 0 | 821 |\n| GolfClubs | 0 | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\n<strong>Explanation:</strong> \nThe quantity for Toaster and Headphones are filled by 0.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef fillMissingValues(products: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11\", \"totalSubmission\": \"11\", \"totalAcceptedRaw\": 11, \"totalSubmissionRaw\": 11, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a build-in function in pandas library to fill the missing values of specified columns."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",32,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",null,9319],[\"Printer\",849,3051]]}}",
"metaData": "{\n \"pythondata\": [\n \"products = pd.DataFrame([], columns=['name', 'quantity', 'price']).astype({'name':'object', 'quantity':'Int64', 'price':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"fillMissingValues\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",32,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",null,9319],[\"Printer\",849,3051]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3076",
"questionFrontendId": "100017",
"categoryTitle": "Algorithms",
"boundTopicId": 2467483,
"title": "Get the Size of a DataFrame",
"titleSlug": "get-the-size-of-a-dataframe",
"content": "<pre>\nDataFrame <code>players:</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| player_id | int |\n| name | object |\n| age | int |\n| position | object |\n| ... | ... |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>\n\n<p>Return the result as an array:</p>\n\n<p><code>[number of rows, number of columns]</code></p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+-----------+----------+-----+-------------+--------------------+\n| player_id | name | age | position | team |\n+-----------+----------+-----+-------------+--------------------+\n| 846 | Mason | 21 | Forward | RealMadrid |\n| 749 | Riley | 30 | Winger | Barcelona |\n| 155 | Bob | 28 | Striker | ManchesterUnited |\n| 583 | Isabella | 32 | Goalkeeper | Liverpool |\n| 388 | Zachary | 24 | Midfielder | BayernMunich |\n| 883 | Ava | 23 | Defender | Chelsea |\n| 355 | Violet | 18 | Striker | Juventus |\n| 247 | Thomas | 27 | Striker | ParisSaint-Germain |\n| 761 | Jack | 33 | Midfielder | ManchesterCity |\n| 642 | Charlie | 36 | Center-back | Arsenal |\n+-----------+----------+-----+-------------+--------------------+<strong>\nOutput:\n</strong>[10, 5]\n<strong>Explanation:</strong>\nThis DataFrame contains 10 rows and 5 columns.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef getDataframeSize(players: pd.DataFrame) -> List[int]:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"18\", \"totalSubmission\": \"18\", \"totalAcceptedRaw\": 18, \"totalSubmissionRaw\": 18, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a built-in function in pandas library to get the size of a DataFrame."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
"metaData": "{\n \"pythondata\": [\n \"players = pd.DataFrame([], columns=['player_id', 'name', 'age', 'position', 'team']).astype({'player_id':'Int64', 'name':'object', 'age':'Int64', 'position':'object', 'team':'object'})\"\n ],\n \"database\": true,\n \"name\": \"get_size\",\n \"languages\": [\n \"pythondata\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,46 @@
{
"data": {
"question": {
"questionId": "3063",
"questionFrontendId": "100004",
"categoryTitle": "Algorithms",
"boundTopicId": 2467482,
"title": "Method Chaining",
"titleSlug": "method-chaining",
"content": "<pre>\nDataFrame <code>animals</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| species | object |\n| age | int |\n| weight | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to list the names of animals that weigh <strong>strictly more than</strong> <code>100</code> kilograms.</p>\n\n<p>Return the&nbsp;animals sorted by weight in <strong>descending order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nDataFrame animals:\n+----------+---------+-----+--------+\n| name | species | age | weight |\n+----------+---------+-----+--------+\n| Tatiana | Snake | 98 | 464 |\n| Khaled | Giraffe | 50 | 41 |\n| Alex | Leopard | 6 | 328 |\n| Jonathan | Monkey | 45 | 463 |\n| Stefan | Bear | 100 | 50 |\n| Tommy | Panda | 26 | 349 |\n+----------+---------+-----+--------+\n<strong>Output:</strong> \n+----------+\n| name |\n+----------+\n| Tatiana |\n| Jonathan |\n| Tommy |\n| Alex |\n+----------+\n<strong>Explanation:</strong> \nAll animals weighing more than 100 should be included in the results table.\nTatiana&#39;s weight is 464, Jonathan&#39;s weight is 463, Tommy&#39;s weight is 349, and Alex&#39;s weight is 328.\nThe results should be sorted in descending order of weight.</pre>\n\n<p>&nbsp;</p>\n<p>In Pandas, <strong>method chaining</strong> enables us to&nbsp;perform operations on a DataFrame without breaking up each operation into a separate line or creating multiple temporary variables.&nbsp;</p>\n\n<p>Can you complete this&nbsp;task in just <strong>one line </strong>of code using method chaining?</p>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [],
"stats": "{\"totalAccepted\": \"1\", \"totalSubmission\": \"1\", \"totalAcceptedRaw\": 1, \"totalSubmissionRaw\": 1, \"acRate\": \"100.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
"metaData": "{\n \"pythondata\": [\n \"animals = pd.DataFrame([], columns=['name', 'species', 'age', 'weight']).astype({'name':'object', 'species':'object', 'age':'Int64', 'weight':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"findHeavyAnimals\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3067",
"questionFrontendId": "2884",
"categoryTitle": "Algorithms",
"boundTopicId": 2467492,
"title": "Modify Columns",
"titleSlug": "modify-columns",
"content": "<pre>\nDataFrame <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>A company intends to give its employees a pay rise.</p>\n\n<p>Write a solution to <strong>modify</strong> the <code>salary</code> column by multiplying each salary by 2.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>DataFrame employees\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Jack | 19666 |\n| Piper | 74754 |\n| Mia | 62509 |\n| Ulysses | 54866 |\n+---------+--------+\n<strong>Output:\n</strong>+---------+--------+\n| name | salary |\n+---------+--------+\n| Jack | 39332 |\n| Piper | 149508 |\n| Mia | 125018 |\n| Ulysses | 109732 |\n+---------+--------+\n<strong>Explanation:\n</strong>Every salary has been doubled.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef modifySalaryColumn(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"15\", \"totalSubmission\": \"15\", \"totalAcceptedRaw\": 15, \"totalSubmissionRaw\": 15, \"acRate\": \"100.0%\"}",
"hints": [
"Considering multiplying each salary value by 2, using a simple assignment operation. The calculation of the value is done column-wise."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Jack\",19666],[\"Piper\",74754],[\"Mia\",62509],[\"Ulysses\",54866]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['name', 'salary']).astype({'name':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"modifySalaryColumn\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Jack\",19666],[\"Piper\",74754],[\"Mia\",62509],[\"Ulysses\",54866]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3068",
"questionFrontendId": "2885",
"categoryTitle": "Algorithms",
"boundTopicId": 2467494,
"title": "Rename Columns",
"titleSlug": "rename-columns",
"content": "<pre>\nDataFrame <code>students</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| id | int |\n| first | object |\n| last | object |\n| age | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to rename the columns as follows:</p>\n\n<ul>\n\t<li><code>id</code> to <code>student_id</code></li>\n\t<li><code>first</code> to <code>first_name</code></li>\n\t<li><code>last</code> to <code>last_name</code></li>\n\t<li><code>age</code> to <code>age_in_years</code></li>\n</ul>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:\n</strong>+----+---------+----------+-----+\n| id | first | last | age |\n+----+---------+----------+-----+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+----+---------+----------+-----+\n<strong>Output:</strong>\n+------------+------------+-----------+--------------+\n| student_id | first_name | last_name | age_in_years |\n+------------+------------+-----------+--------------+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+------------+------------+-----------+--------------+\n<strong>Explanation:</strong> \nThe column names are changed accordingly.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef renameColumns(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"15\", \"totalSubmission\": \"15\", \"totalAcceptedRaw\": 15, \"totalSubmissionRaw\": 15, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a build-in function in pandas library with a dictionary to rename the columns as specified."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['id', 'first', 'last', 'age']).astype({'id':'Int64', 'first':'object', 'last':'object', 'age':'Int64'})\\n\"\n ],\n \"database\": true,\n \"name\": \"renameColumns\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3064",
"questionFrontendId": "100005",
"categoryTitle": "Algorithms",
"boundTopicId": 2453767,
"title": "Reshape Data: Concatenate",
"titleSlug": "reshape-data-concatenate",
"content": "<pre>\nDataFrame <code>df1</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\nDataFrame <code>df2</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>Write a solution to concatenate these two DataFrames <strong>vertically</strong> into one DataFrame.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\ndf1</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n+------------+---------+-----+\n<strong>df2\n</strong>+------------+------+-----+\n| student_id | name | age |\n+------------+------+-----+\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+------+-----+\n<strong>Output:</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+---------+-----+\n<strong>Explanation:\n</strong>The two DataFramess are stacked vertically, and their rows are combined.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef concatenateTables(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"12\", \"totalSubmission\": \"12\", \"totalAcceptedRaw\": 12, \"totalSubmissionRaw\": 12, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a built-in function in pandas library with the appropriate axis argument."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
"metaData": "{\n \"pythondata\": [\n \"df1 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\",\n \"df2 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"concatenateTables\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3073",
"questionFrontendId": "100014",
"categoryTitle": "Algorithms",
"boundTopicId": 2467495,
"title": "Reshape Data: Melt",
"titleSlug": "reshape-data-melt",
"content": "<pre>\nDataFrame <code>report</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| product | object |\n| quarter_1 | int |\n| quarter_2 | int |\n| quarter_3 | int |\n| quarter_4 | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to <strong>reshape</strong> the data so that each row represents sales data for a product in a specific quarter.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+-------------+-----------+-----------+-----------+-----------+\n| product | quarter_1 | quarter_2 | quarter_3 | quarter_4 |\n+-------------+-----------+-----------+-----------+-----------+\n| Umbrella | 417 | 224 | 379 | 611 |\n| SleepingBag | 800 | 936 | 93 | 875 |\n+-------------+-----------+-----------+-----------+-----------+\n<strong>Output:</strong>\n+-------------+-----------+-------+\n| product | quarter | sales |\n+-------------+-----------+-------+\n| Umbrella | quarter_1 | 417 |\n| SleepingBag | quarter_1 | 800 |\n| Umbrella | quarter_2 | 224 |\n| SleepingBag | quarter_2 | 936 |\n| Umbrella | quarter_3 | 379 |\n| SleepingBag | quarter_3 | 93 |\n| Umbrella | quarter_4 | 611 |\n| SleepingBag | quarter_4 | 875 |\n+-------------+-----------+-------+\n<strong>Explanation:</strong>\nThe DataFrame is reshaped from wide to long format. Each row represents the sales of a product in a quarter.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef meltTable(report: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"12\", \"totalSubmission\": \"13\", \"totalAcceptedRaw\": 12, \"totalSubmissionRaw\": 13, \"acRate\": \"92.3%\"}",
"hints": [
"Consider using a built-in function in pandas library to transform the data"
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"report\":[\"product\",\"quarter_1\",\"quarter_2\",\"quarter_3\",\"quarter_4\"]},\"rows\":{\"report\":[[\"Umbrella\",417,224,379,611],[\"SleepingBag\",800,936,93,875]]}}",
"metaData": "{\n \"pythondata\": [\n \"report = pd.DataFrame([], columns=['product', 'quarter_1', 'quarter_2', 'quarter_3', 'quarter_4']).astype({'product':'object', 'quarter_1':'Int64', 'quarter_2':'Int64', 'quarter_3':'Int64', 'quarter_4':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"meltTable\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"report\":[\"product\",\"quarter_1\",\"quarter_2\",\"quarter_3\",\"quarter_4\"]},\"rows\":{\"report\":[[\"Umbrella\",417,224,379,611],[\"SleepingBag\",800,936,93,875]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3072",
"questionFrontendId": "100013",
"categoryTitle": "Algorithms",
"boundTopicId": 2467493,
"title": "Reshape Data: Pivot",
"titleSlug": "reshape-data-pivot",
"content": "<pre>\nDataFrame <code>weather</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| city | object |\n| month | object |\n| temperature | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to <strong>pivot</strong> the data so that each row represents temperatures for a specific month, and each city is a separate column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>\n+--------------+----------+-------------+\n| city | month | temperature |\n+--------------+----------+-------------+\n| Jacksonville | January | 13 |\n| Jacksonville | February | 23 |\n| Jacksonville | March | 38 |\n| Jacksonville | April | 5 |\n| Jacksonville | May | 34 |\n| ElPaso | January | 20 |\n| ElPaso | February | 6 |\n| ElPaso | March | 26 |\n| ElPaso | April | 2 |\n| ElPaso | May | 43 |\n+--------------+----------+-------------+\n<strong>Output:</strong><code>\n+----------+--------+--------------+\n| month | ElPaso | Jacksonville |\n+----------+--------+--------------+\n| April | 2 | 5 |\n| February | 6 | 23 |\n| January | 20 | 13 |\n| March | 26 | 38 |\n| May | 43 | 34 |\n+----------+--------+--------------+</code>\n<strong>Explanation:\n</strong>The table is pivoted, each column represents a city, and each row represents a specific month.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef pivotTable(weather: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11\", \"totalSubmission\": \"11\", \"totalAcceptedRaw\": 11, \"totalSubmissionRaw\": 11, \"acRate\": \"100.0%\"}",
"hints": [
"Consider using a built-in function in pandas library to transform the data"
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"weather\":[\"city\",\"month\",\"temperature\"]},\"rows\":{\"weather\":[[\"Jacksonville\",\"January\",13],[\"Jacksonville\",\"February\",23],[\"Jacksonville\",\"March\",38],[\"Jacksonville\",\"April\",5],[\"Jacksonville\",\"May\",34],[\"ElPaso\",\"January\",20],[\"ElPaso\",\"February\",6],[\"ElPaso\",\"March\",26],[\"ElPaso\",\"April\",2],[\"ElPaso\",\"May\",43]]}}",
"metaData": "{\n \"pythondata\": [\n \"weather = pd.DataFrame([], columns=['city', 'month', 'temperature']).astype({'city':'object', 'month':'object', 'temperature':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"pivot_table\",\n \"languages\": [\n \"pythondata\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"weather\":[\"city\",\"month\",\"temperature\"]},\"rows\":{\"weather\":[[\"Jacksonville\",\"January\",13],[\"Jacksonville\",\"February\",23],[\"Jacksonville\",\"March\",38],[\"Jacksonville\",\"April\",5],[\"Jacksonville\",\"May\",34],[\"ElPaso\",\"January\",20],[\"ElPaso\",\"February\",6],[\"ElPaso\",\"March\",26],[\"ElPaso\",\"April\",2],[\"ElPaso\",\"May\",43]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "3074",
"questionFrontendId": "100015",
"categoryTitle": "Algorithms",
"boundTopicId": 2467487,
"title": "Select Data",
"titleSlug": "select-data",
"content": "<pre>\nDataFrame students\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>Write a solution to select the name and age of the student with <code>student_id = 101</code>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong>Example 1:\nInput:</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 101 | Ulysses | 13 |\n| 53 | William | 10 |\n| 128 | Henry | 6 |\n| 3 | Henry | 11 |\n+------------+---------+-----+\n<strong>Output:</strong>\n+---------+-----+\n| name | age | \n+---------+-----+\n| Ulysses | 13 |\n+---------+-----+\n<strong>Explanation:\n</strong>Student Ulysses has student_id = 101, we select the name and age.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef selectData(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"13\", \"totalSubmission\": \"13\", \"totalAcceptedRaw\": 13, \"totalSubmissionRaw\": 13, \"acRate\": \"100.0%\"}",
"hints": [
"Consider applying both row and column filtering to select the desired data."
],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[101,\"Ulysses\",13],[53,\"William\",10],[128,\"Henry\",6],[3,\"Henry\",11]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"selectData\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[101,\"Ulysses\",13],[53,\"William\",10],[128,\"Henry\",6],[3,\"Henry\",11]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的正整数数组&nbsp;<code>nums</code>&nbsp;</p>
<p>你可以对数组执行以下两种操作 <strong>任意次</strong>&nbsp;</p>
<ul>
<li>从数组中选择 <strong>两个</strong>&nbsp;<strong>相等</strong>&nbsp;的元素,并将它们从数组中 <strong>删除</strong>&nbsp;</li>
<li>从数组中选择 <strong>三个</strong>&nbsp;<strong>相等</strong>&nbsp;的元素,并将它们从数组中 <strong>删除</strong>&nbsp;</li>
</ul>
<p>请你返回使数组为空的 <strong>最少</strong>&nbsp;操作次数,如果无法达成,请返回 <code>-1</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [2,3,3,2,2,4,2,3,4]
<b>输出:</b>4
<b>解释:</b>我们可以执行以下操作使数组为空:
- 对下标为 0 和 3 的元素执行第一种操作,得到 nums = [3,3,2,4,2,3,4] 。
- 对下标为 2 和 4 的元素执行第一种操作,得到 nums = [3,3,4,3,4] 。
- 对下标为 0 1 和 3 的元素执行第二种操作,得到 nums = [4,4] 。
- 对下标为 0 和 1 的元素执行第一种操作,得到 nums = [] 。
至少需要 4 步操作使数组为空。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>nums = [2,1,2,2,3,3]
<b>输出:</b>-1
<b>解释:</b>无法使数组为空。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,51 @@
<p>给你一棵 <code>n</code>&nbsp;个节点的无向树,节点编号为&nbsp;<code>0</code>&nbsp;&nbsp;<code>n - 1</code>&nbsp;。给你整数&nbsp;<code>n</code>&nbsp;和一个长度为 <code>n - 1</code>&nbsp;的二维整数数组&nbsp;<code>edges</code>&nbsp;,其中&nbsp;<code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code>&nbsp;表示树中节点&nbsp;<code>a<sub>i</sub></code>&nbsp;<code>b<sub>i</sub></code>&nbsp;有一条边。</p>
<p>同时给你一个下标从 <strong>0</strong>&nbsp;开始长度为 <code>n</code>&nbsp;的整数数组&nbsp;<code>values</code>&nbsp;,其中&nbsp;<code>values[i]</code>&nbsp;是第 <code>i</code>&nbsp;个节点的 <strong></strong>&nbsp;。再给你一个整数&nbsp;<code>k</code>&nbsp;</p>
<p>你可以从树中删除一些边,也可以一条边也不删,得到若干连通块。一个 <strong>连通块的值</strong> 定义为连通块中所有节点值之和。如果所有连通块的值都可以被 <code>k</code>&nbsp;整除,那么我们说这是一个 <strong>合法分割</strong>&nbsp;</p>
<p>请你返回所有合法分割中,<b>连通块数目的最大值</b>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example12-cropped2svg.jpg" style="width: 1024px; height: 453px;" /></p>
<pre>
<b>输入:</b>n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
<b>输出:</b>2
<b>解释:</b>我们删除节点 1 和 2 之间的边。这是一个合法分割,因为:
- 节点 1 和 3 所在连通块的值为 values[1] + values[3] = 12 。
- 节点 0 2 和 4 所在连通块的值为 values[0] + values[2] + values[4] = 6 。
最多可以得到 2 个连通块的合法分割。</pre>
<p><strong class="example">示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example21svg-1.jpg" style="width: 999px; height: 338px;" /></p>
<pre>
<b>输入:</b>n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
<b>输出:</b>3
<b>解释:</b>我们删除节点 0 和 2 ,以及节点 0 和 1 之间的边。这是一个合法分割,因为:
- 节点 0 的连通块的值为 values[0] = 3 。
- 节点 2 5 和 6 所在连通块的值为 values[2] + values[5] + values[6] = 9 。
- 节点 1 3 和 4 的连通块的值为 values[1] + values[3] + values[4] = 6 。
最多可以得到 3 个连通块的合法分割。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>edges.length == n - 1</code></li>
<li><code>edges[i].length == 2</code></li>
<li><code>0 &lt;= a<sub>i</sub>, b<sub>i</sub> &lt; n</code></li>
<li><code>values.length == n</code></li>
<li><code>0 &lt;= values[i] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>9</sup></code></li>
<li><code>values</code>&nbsp;之和可以被 <code>k</code>&nbsp;整除。</li>
<li>输入保证&nbsp;<code>edges</code>&nbsp;是一棵无向树。</li>
</ul>

View File

@ -0,0 +1,47 @@
<p>给你一个只包含 <strong>非负</strong>&nbsp;整数的数组&nbsp;<code>nums</code>&nbsp;</p>
<p>我们定义满足 <code>l &lt;= r</code>&nbsp;的子数组&nbsp;<code>nums[l..r]</code>&nbsp;的分数为&nbsp;<code>nums[l] AND nums[l + 1] AND ... AND nums[r]</code>&nbsp;,其中&nbsp;<strong>AND</strong>&nbsp;是按位与运算。</p>
<p>请你将数组分割成一个或者更多子数组,满足:</p>
<ul>
<li><strong>每个</strong> 元素都&nbsp;<strong></strong>&nbsp;属于一个子数组。</li>
<li>子数组分数之和尽可能<strong>&nbsp;</strong>&nbsp;</li>
</ul>
<p>请你在满足以上要求的条件下,返回<strong>&nbsp;最多</strong>&nbsp;可以得到多少个子数组。</p>
<p>一个 <strong>子数组</strong>&nbsp;是一个数组中一段连续的元素。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>nums = [1,0,2,0,1,2]
<b>输出:</b>3
<strong>解释:</strong>我们可以将数组分割成以下子数组:
- [1,0] 。子数组分数为 1 AND 0 = 0 。
- [2,0] 。子数组分数为 2 AND 0 = 0 。
- [1,2] 。子数组分数为 1 AND 2 = 0 。
分数之和为 0 + 0 + 0 = 0 ,是我们可以得到的最小分数之和。
在分数之和为 0 的前提下,最多可以将数组分割成 3 个子数组。所以返回 3 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>nums = [5,7,1,3]
<b>输出:</b>1
<b>解释:</b>我们可以将数组分割成一个子数组:[5,7,1,3] ,分数为 1 ,这是可以得到的最小总分数。
在总分数为 1 的前提下,最多可以将数组分割成 1 个子数组。所以返回 1 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,42 @@
<p>给你一个正整数数组&nbsp;<code>nums</code>&nbsp;和一个整数&nbsp;<code>k</code>&nbsp;</p>
<p>一次操作中,你可以将数组的最后一个元素删除,将该元素添加到一个集合中。</p>
<p>请你返回收集元素&nbsp;<code>1, 2, ..., k</code>&nbsp;需要的&nbsp;<strong>最少操作次数</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>nums = [3,1,5,4,2], k = 2
<b>输出:</b>4
<b>解释:</b>4 次操作后,集合中的元素依次添加了 2 4 5 和 1 。此时集合中包含元素 1 和 2 ,所以答案为 4 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>nums = [3,1,5,4,2], k = 5
<b>输出:</b>5
<b>解释:</b>5 次操作后,集合中的元素依次添加了 2 4 5 1 和 3 。此时集合中包含元素 1 到 5 ,所以答案为 5 。
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<b>输入:</b>nums = [3,2,5,3,1], k = 3
<b>输出:</b>4
<b>解释:</b>4 次操作后,集合中的元素依次添加了 1 3 5 和 2 。此时集合中包含元素 1 到 3 ,所以答案为 4 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
<li><code>1 &lt;= nums[i] &lt;= nums.length</code></li>
<li><code>1 &lt;= k &lt;= nums.length</code></li>
<li>输入保证你可以收集到元素&nbsp;<code>1, 2, ..., k</code></li>
</ul>

View File

@ -0,0 +1,45 @@
<p>给你一个下标从 <strong>0</strong> 开始的数组 <code>nums</code> 和一个整数 <code>target</code></p>
<p>下标从 <strong>0</strong> 开始的数组 <code>infinite_nums</code> 是通过无限地将 nums 的元素追加到自己之后生成的。</p>
<p>请你从 <code>infinite_nums</code> 中找出满足 <strong>元素和</strong> 等于&nbsp;<code>target</code><strong>最短</strong> 子数组,并返回该子数组的长度。如果不存在满足条件的子数组,返回 <code>-1</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3], target = 5
<strong>输出:</strong>2
<strong>解释:</strong>在这个例子中 infinite_nums = [1,2,3,1,2,3,1,2,...] 。
区间 [1,2] 内的子数组的元素和等于 target = 5 ,且长度 length = 2 。
可以证明,当元素和等于目标值 target = 5 时2 是子数组的最短长度。</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,1,1,2,3], target = 4
<strong>输出:</strong>2
<strong>解释:</strong>在这个例子中 infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].
区间 [4,5] 内的子数组的元素和等于 target = 4 ,且长度 length = 2 。
可以证明,当元素和等于目标值 target = 4 时2 是子数组的最短长度。
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [2,4,6,8], target = 3
<strong>输出:</strong>-1
<strong>解释:</strong>在这个例子中 infinite_nums = [2,4,6,8,2,4,6,8,...] 。
可以证明,不存在元素和等于目标值 target = 3 的子数组。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,44 @@
<p>现有一个有向图,其中包含 <code>n</code> 个节点,节点编号从 <code>0</code><code>n - 1</code> 。此外,该图还包含了 <code>n</code> 条有向边。</p>
<p>给你一个下标从 <strong>0</strong> 开始的数组 <code>edges</code> ,其中 <code>edges[i]</code> 表示存在一条从节点 <code>i</code> 到节点 <code>edges[i]</code> 的边。</p>
<p>想象在图上发生以下过程:</p>
<ul>
<li>你从节点 <code>x</code> 开始,通过边访问其他节点,直到你在<strong> 此过程 </strong>中再次访问到之前已经访问过的节点。</li>
</ul>
<p>返回数组 <code>answer</code> 作为答案,其中 <code>answer[i]</code> 表示如果从节点 <code>i</code> 开始执行该过程,你可以访问到的不同节点数。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaphdrawio-1.png" />
<pre>
<strong>输入:</strong>edges = [1,2,0,0]
<strong>输出:</strong>[3,3,3,4]
<strong>解释:</strong>从每个节点开始执行该过程,记录如下:
- 从节点 0 开始,访问节点 0 -&gt; 1 -&gt; 2 -&gt; 0 。访问的不同节点数是 3 。
- 从节点 1 开始,访问节点 1 -&gt; 2 -&gt; 0 -&gt; 1 。访问的不同节点数是 3 。
- 从节点 2 开始,访问节点 2 -&gt; 0 -&gt; 1 -&gt; 2 。访问的不同节点数是 3 。
- 从节点 3 开始,访问节点 3 -&gt; 0 -&gt; 1 -&gt; 2 -&gt; 0 。访问的不同节点数是 4 。
</pre>
<p><strong class="example">示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaph2drawio.png" style="width: 191px; height: 251px;" />
<pre>
<strong>输入:</strong>edges = [1,2,3,4,0]
<strong>输出:</strong>[5,5,5,5,5]
<strong>解释:</strong>无论从哪个节点开始,在这个过程中,都可以访问到图中的每一个节点。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == edges.length</code></li>
<li><code>2 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= edges[i] &lt;= n - 1</code></li>
<li><code>edges[i] != i</code></li>
</ul>

View File

@ -0,0 +1,42 @@
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code></p>
<p>请你从所有满足&nbsp;<code>i &lt; j &lt; k</code> 的下标三元组 <code>(i, j, k)</code> 中,找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数,则返回 <code>0</code></p>
<p><strong>下标三元组</strong> <code>(i, j, k)</code> 的值等于 <code>(nums[i] - nums[j]) * nums[k]</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [12,6,1,2,7]
<strong>输出:</strong>77
<strong>解释:</strong>下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,10,3,4,19]
<strong>输出:</strong>133
<strong>解释:</strong>下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3]
<strong>输出:</strong>0
<strong>解释:</strong>唯一的下标三元组 (0, 1, 2) 的值是一个负数,(nums[0] - nums[1]) * nums[2] = -3 。因此,答案是 0 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,42 @@
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code></p>
<p>请你从所有满足&nbsp;<code>i &lt; j &lt; k</code> 的下标三元组 <code>(i, j, k)</code> 中,找出并返回下标三元组的最大值。如果所有满足条件的三元组的值都是负数,则返回 <code>0</code></p>
<p><strong>下标三元组</strong> <code>(i, j, k)</code> 的值等于 <code>(nums[i] - nums[j]) * nums[k]</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [12,6,1,2,7]
<strong>输出:</strong>77
<strong>解释:</strong>下标三元组 (0, 2, 4) 的值是 (nums[0] - nums[2]) * nums[4] = 77 。
可以证明不存在值大于 77 的有序下标三元组。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,10,3,4,19]
<strong>输出:</strong>133
<strong>解释:</strong>下标三元组 (1, 2, 4) 的值是 (nums[1] - nums[2]) * nums[4] = 133 。
可以证明不存在值大于 133 的有序下标三元组。
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3]
<strong>输出:</strong>0
<strong>解释:</strong>唯一的下标三元组 (0, 1, 2) 的值是一个负数,(nums[0] - nums[1]) * nums[2] = -3 。因此,答案是 0 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of positive integers.</p>
<p>There are two types of operations that you can apply on the array <strong>any</strong> number of times:</p>
<ul>
<li>Choose <strong>two</strong> elements with <strong>equal</strong> values and <strong>delete</strong> them from the array.</li>
<li>Choose <strong>three</strong> elements with <strong>equal</strong> values and <strong>delete</strong> them from the array.</li>
</ul>
<p>Return <em>the <strong>minimum</strong> number of operations required to make the array empty, or </em><code>-1</code><em> if it is not possible</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,3,3,2,2,4,2,3,4]
<strong>Output:</strong> 4
<strong>Explanation:</strong> We can apply the following operations to make the array empty:
- Apply the first operation on the elements at indices 0 and 3. The resulting array is nums = [3,3,2,4,2,3,4].
- Apply the first operation on the elements at indices 2 and 4. The resulting array is nums = [3,3,4,3,4].
- Apply the second operation on the elements at indices 0, 1, and 3. The resulting array is nums = [4,4].
- Apply the first operation on the elements at indices 0 and 1. The resulting array is nums = [].
It can be shown that we cannot make the array empty in less than 4 operations.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,1,2,2,3,3]
<strong>Output:</strong> -1
<strong>Explanation:</strong> It is impossible to empty the array.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,45 @@
<p>There is an undirected tree with <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. You are given the integer <code>n</code> and a 2D integer array <code>edges</code> of length <code>n - 1</code>, where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge between nodes <code>a<sub>i</sub></code> and <code>b<sub>i</sub></code> in the tree.</p>
<p>You are also given a <strong>0-indexed</strong> integer array <code>values</code> of length <code>n</code>, where <code>values[i]</code> is the <strong>value</strong> associated with the <code>i<sup>th</sup></code> node, and an integer <code>k</code>.</p>
<p>A <strong>valid split</strong> of the tree is obtained by removing any set of edges, possibly empty, from the tree such that the resulting components all have values that are divisible by <code>k</code>, where the <strong>value of a connected component</strong> is the sum of the values of its nodes.</p>
<p>Return <em>the <strong>maximum number of components</strong> in any valid split</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example12-cropped2svg.jpg" style="width: 1024px; height: 453px;" />
<pre>
<strong>Input:</strong> n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
<strong>Output:</strong> 2
<strong>Explanation:</strong> We remove the edge connecting node 1 with 2. The resulting split is valid because:
- The value of the component containing nodes 1 and 3 is values[1] + values[3] = 12.
- The value of the component containing nodes 0, 2, and 4 is values[0] + values[2] + values[4] = 6.
It can be shown that no other valid split has more than 2 connected components.</pre>
<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example21svg-1.jpg" style="width: 999px; height: 338px;" />
<pre>
<strong>Input:</strong> n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
<strong>Output:</strong> 3
<strong>Explanation:</strong> We remove the edge connecting node 0 with 2, and the edge connecting node 0 with 1. The resulting split is valid because:
- The value of the component containing node 0 is values[0] = 3.
- The value of the component containing nodes 2, 5, and 6 is values[2] + values[5] + values[6] = 9.
- The value of the component containing nodes 1, 3, and 4 is values[1] + values[3] + values[4] = 6.
It can be shown that no other valid split has more than 3 connected components.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>edges.length == n - 1</code></li>
<li><code>edges[i].length == 2</code></li>
<li><code>0 &lt;= a<sub>i</sub>, b<sub>i</sub> &lt; n</code></li>
<li><code>values.length == n</code></li>
<li><code>0 &lt;= values[i] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>9</sup></code></li>
<li>Sum of <code>values</code> is divisible by <code>k</code>.</li>
<li>The input is generated such that <code>edges</code> represents a valid tree.</li>
</ul>

View File

@ -0,0 +1,45 @@
<p>You are given an array <code>nums</code> consisting of <strong>non-negative</strong> integers.</p>
<p>We define the score of subarray <code>nums[l..r]</code> such that <code>l &lt;= r</code> as <code>nums[l] AND nums[l + 1] AND ... AND nums[r]</code> where <strong>AND</strong> is the bitwise <code>AND</code> operation.</p>
<p>Consider splitting the array into one or more subarrays such that the following conditions are satisfied:</p>
<ul>
<li><strong>E</strong><strong>ach</strong> element of the array belongs to <strong>exactly</strong> one subarray.</li>
<li>The sum of scores of the subarrays is the <strong>minimum</strong> possible.</li>
</ul>
<p>Return <em>the <strong>maximum</strong> number of subarrays in a split that satisfies the conditions above.</em></p>
<p>A <strong>subarray</strong> is a contiguous part of an array.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,0,2,0,1,2]
<strong>Output:</strong> 3
<strong>Explanation:</strong> We can split the array into the following subarrays:
- [1,0]. The score of this subarray is 1 AND 0 = 0.
- [2,0]. The score of this subarray is 2 AND 0 = 0.
- [1,2]. The score of this subarray is 1 AND 2 = 0.
The sum of scores is 0 + 0 + 0 = 0, which is the minimum possible score that we can obtain.
It can be shown that we cannot split the array into more than 3 subarrays with a total score of 0. So we return 3.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [5,7,1,3]
<strong>Output:</strong> 1
<strong>Explanation:</strong> We can split the array into one subarray: [5,7,1,3] with a score of 1, which is the minimum possible score that we can obtain.
It can be shown that we cannot split the array into more than 1 subarray with a total score of 1. So we return 1.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given an array <code>nums</code> of positive integers and an integer <code>k</code>.</p>
<p>In one operation, you can remove the last element of the array and add it to your collection.</p>
<p>Return <em>the <strong>minimum number of operations</strong> needed to collect elements</em> <code>1, 2, ..., k</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,1,5,4,2], k = 2
<strong>Output:</strong> 4
<strong>Explanation:</strong> After 4 operations, we collect elements 2, 4, 5, and 1, in this order. Our collection contains elements 1 and 2. Hence, the answer is 4.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,1,5,4,2], k = 5
<strong>Output:</strong> 5
<strong>Explanation:</strong> After 5 operations, we collect elements 2, 4, 5, 1, and 3, in this order. Our collection contains elements 1 through 5. Hence, the answer is 5.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,2,5,3,1], k = 3
<strong>Output:</strong> 4
<strong>Explanation:</strong> After 4 operations, we collect elements 1, 3, 5, and 2, in this order. Our collection contains elements 1 through 3. Hence, the answer is 4.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
<li><code>1 &lt;= nums[i] &lt;= nums.length</code></li>
<li><code>1 &lt;= k &lt;= nums.length</code></li>
<li>The input is generated such that you can collect elements <code>1, 2, ..., k</code>.</li>
</ul>

View File

@ -0,0 +1,44 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> and an integer <code>target</code>.</p>
<p>A <strong>0-indexed</strong> array <code>infinite_nums</code> is generated by infinitely appending the elements of <code>nums</code> to itself.</p>
<p>Return <em>the length of the <strong>shortest</strong> subarray of the array </em><code>infinite_nums</code><em> with a sum equal to </em><code>target</code><em>.</em> If there is no such subarray return <code>-1</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3], target = 5
<strong>Output:</strong> 2
<strong>Explanation:</strong> In this example infinite_nums = [1,2,3,1,2,3,1,2,...].
The subarray in the range [1,2], has the sum equal to target = 5 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 5.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,1,1,2,3], target = 4
<strong>Output:</strong> 2
<strong>Explanation:</strong> In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].
The subarray in the range [4,5], has the sum equal to target = 4 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 4.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,4,6,8], target = 3
<strong>Output:</strong> -1
<strong>Explanation:</strong> In this example infinite_nums = [2,4,6,8,2,4,6,8,...].
It can be proven that there is no subarray with sum equal to target = 3.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,42 @@
<p>There is a <strong>directed</strong> graph consisting of <code>n</code> nodes numbered from <code>0</code> to <code>n - 1</code> and <code>n</code> directed edges.</p>
<p>You are given a <strong>0-indexed</strong> array <code>edges</code> where <code>edges[i]</code> indicates that there is an edge from node <code>i</code> to node <code>edges[i]</code>.</p>
<p>Consider the following process on the graph:</p>
<ul>
<li>You start from a node <code>x</code> and keep visiting other nodes through edges until you reach a node that you have already visited before on this <strong>same</strong> process.</li>
</ul>
<p>Return <em>an array </em><code>answer</code><em> where </em><code>answer[i]</code><em> is the number of <strong>different</strong> nodes that you will visit if you perform the process starting from node </em><code>i</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaphdrawio-1.png" />
<pre>
<strong>Input:</strong> edges = [1,2,0,0]
<strong>Output:</strong> [3,3,3,4]
<strong>Explanation:</strong> We perform the process starting from each node in the following way:
- Starting from node 0, we visit the nodes 0 -&gt; 1 -&gt; 2 -&gt; 0. The number of different nodes we visit is 3.
- Starting from node 1, we visit the nodes 1 -&gt; 2 -&gt; 0 -&gt; 1. The number of different nodes we visit is 3.
- Starting from node 2, we visit the nodes 2 -&gt; 0 -&gt; 1 -&gt; 2. The number of different nodes we visit is 3.
- Starting from node 3, we visit the nodes 3 -&gt; 0 -&gt; 1 -&gt; 2 -&gt; 0. The number of different nodes we visit is 4.
</pre>
<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaph2drawio.png" style="width: 191px; height: 251px;" />
<pre>
<strong>Input:</strong> edges = [1,2,3,4,0]
<strong>Output:</strong> [5,5,5,5,5]
<strong>Explanation:</strong> Starting from any node we can visit every node in the graph in the process.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == edges.length</code></li>
<li><code>2 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= edges[i] &lt;= n - 1</code></li>
<li><code>edges[i] != i</code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p>
<p>Return <em><strong>the maximum value over all triplets of indices</strong></em> <code>(i, j, k)</code> <em>such that</em> <code>i &lt; j &lt; k</code>. If all such triplets have a negative value, return <code>0</code>.</p>
<p>The <strong>value of a triplet of indices</strong> <code>(i, j, k)</code> is equal to <code>(nums[i] - nums[j]) * nums[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [12,6,1,2,7]
<strong>Output:</strong> 77
<strong>Explanation:</strong> The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,10,3,4,19]
<strong>Output:</strong> 133
<strong>Explanation:</strong> The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3]
<strong>Output:</strong> 0
<strong>Explanation:</strong> The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p>
<p>Return <em><strong>the maximum value over all triplets of indices</strong></em> <code>(i, j, k)</code> <em>such that</em> <code>i &lt; j &lt; k</code><em>. </em>If all such triplets have a negative value, return <code>0</code>.</p>
<p>The <strong>value of a triplet of indices</strong> <code>(i, j, k)</code> is equal to <code>(nums[i] - nums[j]) * nums[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [12,6,1,2,7]
<strong>Output:</strong> 77
<strong>Explanation:</strong> The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,10,3,4,19]
<strong>Output:</strong> 133
<strong>Explanation:</strong> The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3]
<strong>Output:</strong> 0
<strong>Explanation:</strong> The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
{
"data": {
"question": {
"questionId": "3160",
"questionFrontendId": "2893",
"boundTopicId": null,
"title": "Calculate Orders Within Each Interval",
"titleSlug": "calculate-orders-within-each-interval",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\": {\"Orders\": [\"minute\", \"order_count\"]}, \"rows\": {\"Orders\":[[1,0],[2,2],[3,4],[4,6],[5,1],[6,4],[7,1],[8,2],[9,4],[10,1],[11,4],[12,6]]}}",
"categoryTitle": "Database",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"5\", \"totalSubmission\": \"5\", \"totalAcceptedRaw\": 5, \"totalSubmissionRaw\": 5, \"acRate\": \"100.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Orders\": [\"minute\", \"order_count\"]}, \"rows\": {\"Orders\":[[1,0],[2,2],[3,4],[4,6],[5,1],[6,4],[7,1],[8,2],[9,4],[10,1],[11,4],[12,6]]}}",
"metaData": "{\"mysql\": [\"Create table if not exists Orders(minute int, order_count int)\"], \"mssql\": [\"Create table Orders(minute int, order_count int)\"], \"oraclesql\": [\"Create table Orders(minute int, order_count int)\"], \"database\": true, \"name\": \"calculate_runs\", \"languages\": [\"mysql\", \"mssql\", \"oraclesql\"], \"database_schema\": {\"Orders\": {\"minute\": \"INT\", \"order_count\": \"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists Orders(minute int, order_count int)",
"Truncate table Orders",
"insert into Orders (minute, order_count) values ('1', '0')",
"insert into Orders (minute, order_count) values ('2', '2')",
"insert into Orders (minute, order_count) values ('3', '4')",
"insert into Orders (minute, order_count) values ('4', '6')",
"insert into Orders (minute, order_count) values ('5', '1')",
"insert into Orders (minute, order_count) values ('6', '4')",
"insert into Orders (minute, order_count) values ('7', '1')",
"insert into Orders (minute, order_count) values ('8', '2')",
"insert into Orders (minute, order_count) values ('9', '4')",
"insert into Orders (minute, order_count) values ('10', '1')",
"insert into Orders (minute, order_count) values ('11', '4')",
"insert into Orders (minute, order_count) values ('12', '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>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3069",
"questionFrontendId": "2886",
"boundTopicId": null,
"title": "Change Data Type",
"titleSlug": "change-data-type",
"content": "<pre>\nDataFrame <code>students</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n| grade | float |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to correct the errors:</p>\n\n<p>The <code>grade</code> column is stored as floats,&nbsp;convert it to integers.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:\n</strong>DataFrame students:\n+------------+------+-----+-------+\n| student_id | name | age | grade |\n+------------+------+-----+-------+\n| 1 | Ava | 6 | 73.0 |\n| 2 | Kate | 15 | 87.0 |\n+------------+------+-----+-------+\n<strong>Output:\n</strong>+------------+------+-----+-------+\n| student_id | name | age | grade |\n+------------+------+-----+-------+\n| 1 | Ava | 6 | 73 |\n| 2 | Kate | 15 | 87 |\n+------------+------+-----+-------+\n<strong>Explanation:</strong> \nThe data types of the column grade is converted to int.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 2,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\",\"grade\"]},\"rows\":{\"students\":[[1,\"Ava\",6,73.0],[2,\"Kate\",15,87.0]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef changeDatatype(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"235\", \"totalSubmission\": \"258\", \"totalAcceptedRaw\": 235, \"totalSubmissionRaw\": 258, \"acRate\": \"91.1%\"}",
"hints": [
"Consider using a build-in function in pandas library with a dictionary to convert the datatype of columns as specified."
],
"solution": {
"id": "2111",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\",\"grade\"]},\"rows\":{\"students\":[[1,\"Ava\",6,73.0],[2,\"Kate\",15,87.0]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age', 'grade']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64', 'grade':'Float64'})\"\n ],\n \"database\": true,\n \"name\": \"changeDatatype\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3062",
"questionFrontendId": "2877",
"boundTopicId": null,
"title": "Create a DataFrame from List",
"titleSlug": "create-a-dataframe-from-list",
"content": "<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>\n\n<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>student_data:<strong>\n</strong><code>[\n [1, 15],\n [2, 11],\n [3, 11],\n [4, 20]\n]</code>\n<strong>Output:</strong>\n+------------+-----+\n| student_id | age |\n+------------+-----+\n| 1 | 15 |\n| 2 | 11 |\n| 3 | 11 |\n| 4 | 20 |\n+------------+-----+\n<strong>Explanation:</strong>\nA DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 8,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "[[1,15],[2,11],[3,11],[4,20]]",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef createDataframe(student_data: List[List[int]]) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"473\", \"totalSubmission\": \"564\", \"totalAcceptedRaw\": 473, \"totalSubmissionRaw\": 564, \"acRate\": \"83.9%\"}",
"hints": [
"Consider using a built-in function in pandas library and specifying the column names within it."
],
"solution": {
"id": "2099",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "[[1,15],[2,11],[3,11],[4,20]]",
"metaData": "{\n \"name\": \"create_a_dataframe\",\n \"params\": [\n {\n \"name\": \"student_data\",\n \"type\": \"list<list<integer>>\"\n }\n ],\n \"return\": {\n \"type\": \"DataFrame\"\n },\n \"data\": true,\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3066",
"questionFrontendId": "2881",
"boundTopicId": null,
"title": "Create a New Column",
"titleSlug": "create-a-new-column",
"content": "<pre>\nDataFrame <code>employees</code>\n+-------------+--------+\n| Column Name | Type. |\n+-------------+--------+\n| name | object |\n| salary | int. |\n+-------------+--------+\n</pre>\n\n<p>A&nbsp;company plans to provide its employees with a bonus.</p>\n\n<p>Write a solution to create a new column name <code>bonus</code> that contains the <strong>doubled values</strong> of the <code>salary</code> column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong>\nDataFrame employees\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Piper | 4548 |\n| Grace | 28150 |\n| Georgia | 1103 |\n| Willow | 6593 |\n| Finn | 74576 |\n| Thomas | 24433 |\n+---------+--------+\n<strong>Output:</strong>\n+---------+--------+--------+\n| name | salary | bonus |\n+---------+--------+--------+\n| Piper | 4548 | 9096 |\n| Grace | 28150 | 56300 |\n| Georgia | 1103 | 2206 |\n| Willow | 593 | 13186 |\n| Finn | 74576 | 149152 |\n| Thomas | 24433 | 48866 |\n+---------+--------+--------+\n<strong>Explanation:</strong> \nA new column bonus is created by doubling the value in the column salary.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 5,
"dislikes": 2,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Piper\",4548],[\"Grace\",28150],[\"Georgia\",1103],[\"Willow\",6593],[\"Finn\",74576],[\"Thomas\",24433]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef createBonusColumn(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"315\", \"totalSubmission\": \"337\", \"totalAcceptedRaw\": 315, \"totalSubmissionRaw\": 337, \"acRate\": \"93.5%\"}",
"hints": [
"Consider using the `[]` brackets with the new column name at the left side of the assignment. The calculation of the value is done element-wise."
],
"solution": {
"id": "2103",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Piper\",4548],[\"Grace\",28150],[\"Georgia\",1103],[\"Willow\",6593],[\"Finn\",74576],[\"Thomas\",24433]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['name', 'salary']).astype({'name':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"createBonusColumn\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3065",
"questionFrontendId": "2879",
"boundTopicId": null,
"title": "Display the First Three Rows",
"titleSlug": "display-the-first-three-rows",
"content": "<pre>\nDataFrame: <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| employee_id | int |\n| name | object |\n| department | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>DataFrame employees\n+-------------+-----------+-----------------------+--------+\n| employee_id | name | department | salary |\n+-------------+-----------+-----------------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n| 60 | Annabelle | InformationTechnology | 37678 |\n| 49 | Jonathan | HumanResources | 23793 |\n| 43 | Khaled | Administration | 40454 |\n+-------------+-----------+-----------------------+--------+\n<strong>Output:</strong>\n+-------------+---------+-------------+--------+\n| employee_id | name | department | salary |\n+-------------+---------+-------------+--------+\n| 3 | Bob | Operations | 48675 |\n| 90 | Alice | Sales | 11096 |\n| 9 | Tatiana | Engineering | 33805 |\n+-------------+---------+-------------+--------+\n<strong>Explanation:</strong> \nOnly the first 3 rows are displayed.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 3,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"394\", \"totalSubmission\": \"417\", \"totalAcceptedRaw\": 394, \"totalSubmissionRaw\": 417, \"acRate\": \"94.5%\"}",
"hints": [
"Consider using a built-in function in pandas library to retrieve the initial rows."
],
"solution": {
"id": "2101",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"employee_id\",\"name\",\"department\",\"salary\"]},\"rows\":{\"employees\":[[3,\"Bob\",\"Operations\",48675],[90,\"Alice\",\"Sales\",11096],[9,\"Tatiana\",\"Engineering\",33805],[60,\"Annabelle\",\"InformationTechnology\",37678],[49,\"Jonathan\",\"HumanResources\",23793],[43,\"Khaled\",\"Administration\",40454]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['employee_id', 'name', 'department', 'salary']).astype({'employee_id':'Int64', 'name':'object', 'department':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"selectFirstRows\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3071",
"questionFrontendId": "2882",
"boundTopicId": null,
"title": "Drop Duplicate Rows",
"titleSlug": "drop-duplicate-rows",
"content": "<pre>\nDataFrame customers\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| customer_id | int |\n| name | object |\n| email | object |\n+-------------+--------+\n</pre>\n\n<p>There are some duplicate rows in the DataFrame based on the <code>email</code> column.</p>\n\n<p>Write a solution to remove these duplicate rows and keep only the <strong>first</strong> occurrence.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>\n+-------------+---------+---------------------+\n| customer_id | name | email |\n+-------------+---------+---------------------+\n| 1 | Ella | emily@example.com |\n| 2 | David | michael@example.com |\n| 3 | Zachary | sarah@example.com |\n| 4 | Alice | john@example.com |\n| 5 | Finn | john@example.com |\n| 6 | Violet | alice@example.com |\n+-------------+---------+---------------------+\n<strong>Output: </strong> \n+-------------+---------+---------------------+\n| customer_id | name | email |\n+-------------+---------+---------------------+\n| 1 | Ella | emily@example.com |\n| 2 | David | michael@example.com |\n| 3 | Zachary | sarah@example.com |\n| 4 | Alice | john@example.com |\n| 6 | Violet | alice@example.com |\n+-------------+---------+---------------------+\n<strong>Explanation:</strong>\nAlic (customer_id = 4) and Finn (customer_id = 5) both use john@example.com, so only the first occurrence of this email is retained.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 9,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"customers\":[\"customer_id\",\"name\",\"email\"]},\"rows\":{\"customers\":[[1,\"Ella\",\"emily@example.com\"],[2,\"David\",\"michael@example.com\"],[3,\"Zachary\",\"sarah@example.com\"],[4,\"Alice\",\"john@example.com\"],[5,\"Finn\",\"john@example.com\"],[6,\"Violet\",\"alice@example.com\"]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef dropDuplicateEmails(customers: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"242\", \"totalSubmission\": \"276\", \"totalAcceptedRaw\": 242, \"totalSubmissionRaw\": 276, \"acRate\": \"87.7%\"}",
"hints": [
"Consider using a build-in function in pandas library to remove the duplicate rows based on specified data."
],
"solution": {
"id": "2114",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"customers\":[\"customer_id\",\"name\",\"email\"]},\"rows\":{\"customers\":[[1,\"Ella\",\"emily@example.com\"],[2,\"David\",\"michael@example.com\"],[3,\"Zachary\",\"sarah@example.com\"],[4,\"Alice\",\"john@example.com\"],[5,\"Finn\",\"john@example.com\"],[6,\"Violet\",\"alice@example.com\"]]}}",
"metaData": "{\n \"pythondata\": [\n \"customers = pd.DataFrame([], columns=['customer_id', 'name', 'email']).astype({'customer_id':'Int64', 'name':'object', 'email':'object'})\"\n ],\n \"database\": true,\n \"name\": \"dropDuplicateEmails\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3075",
"questionFrontendId": "2883",
"boundTopicId": null,
"title": "Drop Missing Data",
"titleSlug": "drop-missing-data",
"content": "<pre>\nDataFrame students\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n</pre>\n\n<p>There are some rows having missing values in the <code>name</code> column.</p>\n\n<p>Write a solution to remove the rows with missing values.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+------------+-------+-----+\n| student_id | name | age |\n+------------+-------+-----+\n| 32 | Piper | 5 |\n| 217 | Grace | 19 |\n| 779 | None | 20 |\n| 849 | None | 14 |\n+------------+-------+-----+\n<strong>Output:\n</strong>+------------+-------+-----+\n| student_id | name | age |\n+------------+-------+-----+\n| 32 | Piper | 5 |\n| 217 | Grace | 19 |\n+------------+-------+-----+\n<strong>Explanation:</strong> \nStudents with ids 779 and 849 have empty values in the name column, so they will be removed.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 7,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[32,\"Piper\",5],[217,\"Grace\",19],[779,null,20],[849,null,14]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef dropMissingData(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"270\", \"totalSubmission\": \"295\", \"totalAcceptedRaw\": 270, \"totalSubmissionRaw\": 295, \"acRate\": \"91.5%\"}",
"hints": [
"Consider using a build-in function in pandas library to remove the rows with missing values based on specified data."
],
"solution": {
"id": "2108",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[32,\"Piper\",5],[217,\"Grace\",19],[779,null,20],[849,null,14]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"dropMissingData\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3070",
"questionFrontendId": "2887",
"boundTopicId": null,
"title": "Fill Missing Data",
"titleSlug": "fill-missing-data",
"content": "<pre>\nDataFrame <code>products</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| quantity | int |\n| price | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to fill in the missing value as <code><strong>0</strong></code> in the <code>quantity</code> column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | 32 | 135 |\n| WirelessEarbuds | None | 821 |\n| GolfClubs | None | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\n<strong>Output:\n</strong>+-----------------+----------+-------+\n| name | quantity | price |\n+-----------------+----------+-------+\n| Wristwatch | 32 | 135 |\n| WirelessEarbuds | 0 | 821 |\n| GolfClubs | 0 | 9319 |\n| Printer | 849 | 3051 |\n+-----------------+----------+-------+\n<strong>Explanation:</strong> \nThe quantity for Toaster and Headphones are filled by 0.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 8,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",32,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",null,9319],[\"Printer\",849,3051]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef fillMissingValues(products: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"283\", \"totalSubmission\": \"297\", \"totalAcceptedRaw\": 283, \"totalSubmissionRaw\": 297, \"acRate\": \"95.3%\"}",
"hints": [
"Consider using a build-in function in pandas library to fill the missing values of specified columns."
],
"solution": {
"id": "2112",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"products\":[\"name\",\"quantity\",\"price\"]},\"rows\":{\"products\":[[\"Wristwatch\",32,135],[\"WirelessEarbuds\",null,821],[\"GolfClubs\",null,9319],[\"Printer\",849,3051]]}}",
"metaData": "{\n \"pythondata\": [\n \"products = pd.DataFrame([], columns=['name', 'quantity', 'price']).astype({'name':'object', 'quantity':'Int64', 'price':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"fillMissingValues\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3076",
"questionFrontendId": "2878",
"boundTopicId": null,
"title": "Get the Size of a DataFrame",
"titleSlug": "get-the-size-of-a-dataframe",
"content": "<pre>\nDataFrame <code>players:</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| player_id | int |\n| name | object |\n| age | int |\n| position | object |\n| ... | ... |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>\n\n<p>Return the result as an array:</p>\n\n<p><code>[number of rows, number of columns]</code></p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+-----------+----------+-----+-------------+--------------------+\n| player_id | name | age | position | team |\n+-----------+----------+-----+-------------+--------------------+\n| 846 | Mason | 21 | Forward | RealMadrid |\n| 749 | Riley | 30 | Winger | Barcelona |\n| 155 | Bob | 28 | Striker | ManchesterUnited |\n| 583 | Isabella | 32 | Goalkeeper | Liverpool |\n| 388 | Zachary | 24 | Midfielder | BayernMunich |\n| 883 | Ava | 23 | Defender | Chelsea |\n| 355 | Violet | 18 | Striker | Juventus |\n| 247 | Thomas | 27 | Striker | ParisSaint-Germain |\n| 761 | Jack | 33 | Midfielder | ManchesterCity |\n| 642 | Charlie | 36 | Center-back | Arsenal |\n+-----------+----------+-----+-------------+--------------------+<strong>\nOutput:\n</strong>[10, 5]\n<strong>Explanation:</strong>\nThis DataFrame contains 10 rows and 5 columns.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 5,
"dislikes": 2,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef getDataframeSize(players: pd.DataFrame) -> List[int]:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"370\", \"totalSubmission\": \"421\", \"totalAcceptedRaw\": 370, \"totalSubmissionRaw\": 421, \"acRate\": \"87.9%\"}",
"hints": [
"Consider using a built-in function in pandas library to get the size of a DataFrame."
],
"solution": {
"id": "2109",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"players\":[\"player_id\",\"name\",\"age\",\"position\",\"team\"]},\"rows\":{\"players\":[[846,\"Mason\",21,\"Forward\",\"RealMadrid\"],[749,\"Riley\",30,\"Winger\",\"Barcelona\"],[155,\"Bob\",28,\"Striker\",\"ManchesterUnited\"],[583,\"Isabella\",32,\"Goalkeeper\",\"Liverpool\"],[388,\"Zachary\",24,\"Midfielder\",\"BayernMunich\"],[883,\"Ava\",23,\"Defender\",\"Chelsea\"],[355,\"Violet\",18,\"Striker\",\"Juventus\"],[247,\"Thomas\",27,\"Striker\",\"ParisSaint-Germain\"],[761,\"Jack\",33,\"Midfielder\",\"ManchesterCity\"],[642,\"Charlie\",36,\"Center-back\",\"Arsenal\"]]}}",
"metaData": "{\n \"pythondata\": [\n \"players = pd.DataFrame([], columns=['player_id', 'name', 'age', 'position', 'team']).astype({'player_id':'Int64', 'name':'object', 'age':'Int64', 'position':'object', 'team':'object'})\"\n ],\n \"database\": true,\n \"name\": \"get_size\",\n \"languages\": [\n \"pythondata\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,57 @@
{
"data": {
"question": {
"questionId": "3063",
"questionFrontendId": "2891",
"boundTopicId": null,
"title": "Method Chaining",
"titleSlug": "method-chaining",
"content": "<pre>\nDataFrame <code>animals</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| species | object |\n| age | int |\n| weight | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to list the names of animals that weigh <strong>strictly more than</strong> <code>100</code> kilograms.</p>\n\n<p>Return the&nbsp;animals sorted by weight in <strong>descending order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nDataFrame animals:\n+----------+---------+-----+--------+\n| name | species | age | weight |\n+----------+---------+-----+--------+\n| Tatiana | Snake | 98 | 464 |\n| Khaled | Giraffe | 50 | 41 |\n| Alex | Leopard | 6 | 328 |\n| Jonathan | Monkey | 45 | 463 |\n| Stefan | Bear | 100 | 50 |\n| Tommy | Panda | 26 | 349 |\n+----------+---------+-----+--------+\n<strong>Output:</strong> \n+----------+\n| name |\n+----------+\n| Tatiana |\n| Jonathan |\n| Tommy |\n| Alex |\n+----------+\n<strong>Explanation:</strong> \nAll animals weighing more than 100 should be included in the results table.\nTatiana&#39;s weight is 464, Jonathan&#39;s weight is 463, Tommy&#39;s weight is 349, and Alex&#39;s weight is 328.\nThe results should be sorted in descending order of weight.</pre>\n\n<p>&nbsp;</p>\n<p>In Pandas, <strong>method chaining</strong> enables us to&nbsp;perform operations on a DataFrame without breaking up each operation into a separate line or creating multiple temporary variables.&nbsp;</p>\n\n<p>Can you complete this&nbsp;task in just <strong>one line </strong>of code using method chaining?</p>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 5,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"214\", \"totalSubmission\": \"254\", \"totalAcceptedRaw\": 214, \"totalSubmissionRaw\": 254, \"acRate\": \"84.3%\"}",
"hints": [],
"solution": {
"id": "2100",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"animals\":[\"name\",\"species\",\"age\",\"weight\"]},\"rows\":{\"animals\":[[\"Tatiana\",\"Snake\",98,464],[\"Khaled\",\"Giraffe\",50,41],[\"Alex\",\"Leopard\",6,328],[\"Jonathan\",\"Monkey\",45,463],[\"Stefan\",\"Bear\",100,50],[\"Tommy\",\"Panda\",26,349]]}}",
"metaData": "{\n \"pythondata\": [\n \"animals = pd.DataFrame([], columns=['name', 'species', 'age', 'weight']).astype({'name':'object', 'species':'object', 'age':'Int64', 'weight':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"findHeavyAnimals\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3067",
"questionFrontendId": "2884",
"boundTopicId": null,
"title": "Modify Columns",
"titleSlug": "modify-columns",
"content": "<pre>\nDataFrame <code>employees</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| name | object |\n| salary | int |\n+-------------+--------+\n</pre>\n\n<p>A company intends to give its employees a pay rise.</p>\n\n<p>Write a solution to <strong>modify</strong> the <code>salary</code> column by multiplying each salary by 2.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>DataFrame employees\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Jack | 19666 |\n| Piper | 74754 |\n| Mia | 62509 |\n| Ulysses | 54866 |\n+---------+--------+\n<strong>Output:\n</strong>+---------+--------+\n| name | salary |\n+---------+--------+\n| Jack | 39332 |\n| Piper | 149508 |\n| Mia | 125018 |\n| Ulysses | 109732 |\n+---------+--------+\n<strong>Explanation:\n</strong>Every salary has been doubled.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Jack\",19666],[\"Piper\",74754],[\"Mia\",62509],[\"Ulysses\",54866]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef modifySalaryColumn(employees: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"292\", \"totalSubmission\": \"310\", \"totalAcceptedRaw\": 292, \"totalSubmissionRaw\": 310, \"acRate\": \"94.2%\"}",
"hints": [
"Considering multiplying each salary value by 2, using a simple assignment operation. The calculation of the value is done column-wise."
],
"solution": {
"id": "2110",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"employees\":[\"name\",\"salary\"]},\"rows\":{\"employees\":[[\"Jack\",19666],[\"Piper\",74754],[\"Mia\",62509],[\"Ulysses\",54866]]}}",
"metaData": "{\n \"pythondata\": [\n \"employees = pd.DataFrame([], columns=['name', 'salary']).astype({'name':'object', 'salary':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"modifySalaryColumn\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3068",
"questionFrontendId": "2885",
"boundTopicId": null,
"title": "Rename Columns",
"titleSlug": "rename-columns",
"content": "<pre>\nDataFrame <code>students</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| id | int |\n| first | object |\n| last | object |\n| age | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to rename the columns as follows:</p>\n\n<ul>\n\t<li><code>id</code> to <code>student_id</code></li>\n\t<li><code>first</code> to <code>first_name</code></li>\n\t<li><code>last</code> to <code>last_name</code></li>\n\t<li><code>age</code> to <code>age_in_years</code></li>\n</ul>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:\n</strong>+----+---------+----------+-----+\n| id | first | last | age |\n+----+---------+----------+-----+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+----+---------+----------+-----+\n<strong>Output:</strong>\n+------------+------------+-----------+--------------+\n| student_id | first_name | last_name | age_in_years |\n+------------+------------+-----------+--------------+\n| 1 | Mason | King | 6 |\n| 2 | Ava | Wright | 7 |\n| 3 | Taylor | Hall | 16 |\n| 4 | Georgia | Thompson | 18 |\n| 5 | Thomas | Moore | 10 |\n+------------+------------+-----------+--------------+\n<strong>Explanation:</strong> \nThe column names are changed accordingly.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef renameColumns(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"250\", \"totalSubmission\": \"285\", \"totalAcceptedRaw\": 250, \"totalSubmissionRaw\": 285, \"acRate\": \"87.7%\"}",
"hints": [
"Consider using a build-in function in pandas library with a dictionary to rename the columns as specified."
],
"solution": {
"id": "2104",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"id\",\"first\",\"last\",\"age\"]},\"rows\":{\"employees\":[],\"students\":[[1,\"Mason\",\"King\",6],[2,\"Ava\",\"Wright\",7],[3,\"Taylor\",\"Hall\",16],[4,\"Georgia\",\"Thompson\",18],[5,\"Thomas\",\"Moore\",10]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['id', 'first', 'last', 'age']).astype({'id':'Int64', 'first':'object', 'last':'object', 'age':'Int64'})\\n\"\n ],\n \"database\": true,\n \"name\": \"renameColumns\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3064",
"questionFrontendId": "2888",
"boundTopicId": null,
"title": "Reshape Data: Concatenate",
"titleSlug": "reshape-data-concatenate",
"content": "<pre>\nDataFrame <code>df1</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\nDataFrame <code>df2</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>Write a solution to concatenate these two DataFrames <strong>vertically</strong> into one DataFrame.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\ndf1</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n+------------+---------+-----+\n<strong>df2\n</strong>+------------+------+-----+\n| student_id | name | age |\n+------------+------+-----+\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+------+-----+\n<strong>Output:</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 1 | Mason | 8 |\n| 2 | Ava | 6 |\n| 3 | Taylor | 15 |\n| 4 | Georgia | 17 |\n| 5 | Leo | 7 |\n| 6 | Alex | 7 |\n+------------+---------+-----+\n<strong>Explanation:\n</strong>The two DataFramess are stacked vertically, and their rows are combined.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef concatenateTables(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"245\", \"totalSubmission\": \"268\", \"totalAcceptedRaw\": 245, \"totalSubmissionRaw\": 268, \"acRate\": \"91.4%\"}",
"hints": [
"Consider using a built-in function in pandas library with the appropriate axis argument."
],
"solution": {
"id": "2102",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"df1\":[\"student_id\",\"name\",\"age\"],\"df2\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"df1\":[[1,\"Mason\",8],[2,\"Ava\",6],[3,\"Taylor\",15],[4,\"Georgia\",17]],\"df2\":[[5,\"Leo\",7],[6,\"Alex\",7]]}}",
"metaData": "{\n \"pythondata\": [\n \"df1 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\",\n \"df2 = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"concatenateTables\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3073",
"questionFrontendId": "2890",
"boundTopicId": null,
"title": "Reshape Data: Melt",
"titleSlug": "reshape-data-melt",
"content": "<pre>\nDataFrame <code>report</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| product | object |\n| quarter_1 | int |\n| quarter_2 | int |\n| quarter_3 | int |\n| quarter_4 | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to <strong>reshape</strong> the data so that each row represents sales data for a product in a specific quarter.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:\n</strong>+-------------+-----------+-----------+-----------+-----------+\n| product | quarter_1 | quarter_2 | quarter_3 | quarter_4 |\n+-------------+-----------+-----------+-----------+-----------+\n| Umbrella | 417 | 224 | 379 | 611 |\n| SleepingBag | 800 | 936 | 93 | 875 |\n+-------------+-----------+-----------+-----------+-----------+\n<strong>Output:</strong>\n+-------------+-----------+-------+\n| product | quarter | sales |\n+-------------+-----------+-------+\n| Umbrella | quarter_1 | 417 |\n| SleepingBag | quarter_1 | 800 |\n| Umbrella | quarter_2 | 224 |\n| SleepingBag | quarter_2 | 936 |\n| Umbrella | quarter_3 | 379 |\n| SleepingBag | quarter_3 | 93 |\n| Umbrella | quarter_4 | 611 |\n| SleepingBag | quarter_4 | 875 |\n+-------------+-----------+-------+\n<strong>Explanation:</strong>\nThe DataFrame is reshaped from wide to long format. Each row represents the sales of a product in a quarter.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 9,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"report\":[\"product\",\"quarter_1\",\"quarter_2\",\"quarter_3\",\"quarter_4\"]},\"rows\":{\"report\":[[\"Umbrella\",417,224,379,611],[\"SleepingBag\",800,936,93,875]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef meltTable(report: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"165\", \"totalSubmission\": \"187\", \"totalAcceptedRaw\": 165, \"totalSubmissionRaw\": 187, \"acRate\": \"88.2%\"}",
"hints": [
"Consider using a built-in function in pandas library to transform the data"
],
"solution": {
"id": "2105",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"report\":[\"product\",\"quarter_1\",\"quarter_2\",\"quarter_3\",\"quarter_4\"]},\"rows\":{\"report\":[[\"Umbrella\",417,224,379,611],[\"SleepingBag\",800,936,93,875]]}}",
"metaData": "{\n \"pythondata\": [\n \"report = pd.DataFrame([], columns=['product', 'quarter_1', 'quarter_2', 'quarter_3', 'quarter_4']).astype({'product':'object', 'quarter_1':'Int64', 'quarter_2':'Int64', 'quarter_3':'Int64', 'quarter_4':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"meltTable\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3072",
"questionFrontendId": "2889",
"boundTopicId": null,
"title": "Reshape Data: Pivot",
"titleSlug": "reshape-data-pivot",
"content": "<pre>\nDataFrame <code>weather</code>\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| city | object |\n| month | object |\n| temperature | int |\n+-------------+--------+\n</pre>\n\n<p>Write a solution to <strong>pivot</strong> the data so that each row represents temperatures for a specific month, and each city is a separate column.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong class=\"example\">Example 1:</strong>\n<strong>Input:</strong>\n+--------------+----------+-------------+\n| city | month | temperature |\n+--------------+----------+-------------+\n| Jacksonville | January | 13 |\n| Jacksonville | February | 23 |\n| Jacksonville | March | 38 |\n| Jacksonville | April | 5 |\n| Jacksonville | May | 34 |\n| ElPaso | January | 20 |\n| ElPaso | February | 6 |\n| ElPaso | March | 26 |\n| ElPaso | April | 2 |\n| ElPaso | May | 43 |\n+--------------+----------+-------------+\n<strong>Output:</strong><code>\n+----------+--------+--------------+\n| month | ElPaso | Jacksonville |\n+----------+--------+--------------+\n| April | 2 | 5 |\n| February | 6 | 23 |\n| January | 20 | 13 |\n| March | 26 | 38 |\n| May | 43 | 34 |\n+----------+--------+--------------+</code>\n<strong>Explanation:\n</strong>The table is pivoted, each column represents a city, and each row represents a specific month.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 10,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"weather\":[\"city\",\"month\",\"temperature\"]},\"rows\":{\"weather\":[[\"Jacksonville\",\"January\",13],[\"Jacksonville\",\"February\",23],[\"Jacksonville\",\"March\",38],[\"Jacksonville\",\"April\",5],[\"Jacksonville\",\"May\",34],[\"ElPaso\",\"January\",20],[\"ElPaso\",\"February\",6],[\"ElPaso\",\"March\",26],[\"ElPaso\",\"April\",2],[\"ElPaso\",\"May\",43]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef pivotTable(weather: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"175\", \"totalSubmission\": \"204\", \"totalAcceptedRaw\": 175, \"totalSubmissionRaw\": 204, \"acRate\": \"85.8%\"}",
"hints": [
"Consider using a built-in function in pandas library to transform the data"
],
"solution": {
"id": "2106",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"weather\":[\"city\",\"month\",\"temperature\"]},\"rows\":{\"weather\":[[\"Jacksonville\",\"January\",13],[\"Jacksonville\",\"February\",23],[\"Jacksonville\",\"March\",38],[\"Jacksonville\",\"April\",5],[\"Jacksonville\",\"May\",34],[\"ElPaso\",\"January\",20],[\"ElPaso\",\"February\",6],[\"ElPaso\",\"March\",26],[\"ElPaso\",\"April\",2],[\"ElPaso\",\"May\",43]]}}",
"metaData": "{\n \"pythondata\": [\n \"weather = pd.DataFrame([], columns=['city', 'month', 'temperature']).astype({'city':'object', 'month':'object', 'temperature':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"pivot_table\",\n \"languages\": [\n \"pythondata\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

View File

@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "3074",
"questionFrontendId": "2880",
"boundTopicId": null,
"title": "Select Data",
"titleSlug": "select-data",
"content": "<pre>\nDataFrame students\n+-------------+--------+\n| Column Name | Type |\n+-------------+--------+\n| student_id | int |\n| name | object |\n| age | int |\n+-------------+--------+\n\n</pre>\n\n<p>Write a solution to select the name and age of the student with <code>student_id = 101</code>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<pre>\n<strong>Example 1:\nInput:</strong>\n+------------+---------+-----+\n| student_id | name | age |\n+------------+---------+-----+\n| 101 | Ulysses | 13 |\n| 53 | William | 10 |\n| 128 | Henry | 6 |\n| 3 | Henry | 11 |\n+------------+---------+-----+\n<strong>Output:</strong>\n+---------+-----+\n| name | age | \n+---------+-----+\n| Ulysses | 13 |\n+---------+-----+\n<strong>Explanation:\n</strong>Student Ulysses has student_id = 101, we select the name and age.</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 6,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[101,\"Ulysses\",13],[53,\"William\",10],[128,\"Henry\",6],[3,\"Henry\",11]]}}",
"categoryTitle": "Algorithms",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef selectData(students: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"327\", \"totalSubmission\": \"386\", \"totalAcceptedRaw\": 327, \"totalSubmissionRaw\": 386, \"acRate\": \"84.7%\"}",
"hints": [
"Consider applying both row and column filtering to select the desired data."
],
"solution": {
"id": "2107",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true,
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"age\"]},\"rows\":{\"students\":[[101,\"Ulysses\",13],[53,\"William\",10],[128,\"Henry\",6],[3,\"Henry\",11]]}}",
"metaData": "{\n \"pythondata\": [\n \"students = pd.DataFrame([], columns=['student_id', 'name', 'age']).astype({'student_id':'Int64', 'name':'object', 'age':'Int64'})\"\n ],\n \"database\": true,\n \"name\": \"selectData\",\n \"languages\": [\n \"pythondata\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": true,
"envInfo": "{\"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
<pre>
DataFrame <code>students</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
| grade | float |
+-------------+--------+
</pre>
<p>Write a solution to correct the errors:</p>
<p>The <code>grade</code> column is stored as floats,&nbsp;convert it to integers.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong class="example">Example 1:</strong>
<strong>Input:
</strong>DataFrame students:
+------------+------+-----+-------+
| student_id | name | age | grade |
+------------+------+-----+-------+
| 1 | Ava | 6 | 73.0 |
| 2 | Kate | 15 | 87.0 |
+------------+------+-----+-------+
<strong>Output:
</strong>+------------+------+-----+-------+
| student_id | name | age | grade |
+------------+------+-----+-------+
| 1 | Ava | 6 | 73 |
| 2 | Kate | 15 | 87 |
+------------+------+-----+-------+
<strong>Explanation:</strong>
The data types of the column grade is converted to int.</pre>

View File

@ -0,0 +1,42 @@
<p>There is a <strong>directed</strong> graph consisting of <code>n</code> nodes numbered from <code>0</code> to <code>n - 1</code> and <code>n</code> directed edges.</p>
<p>You are given a <strong>0-indexed</strong> array <code>edges</code> where <code>edges[i]</code> indicates that there is an edge from node <code>i</code> to node <code>edges[i]</code>.</p>
<p>Consider the following process on the graph:</p>
<ul>
<li>You start from a node <code>x</code> and keep visiting other nodes through edges until you reach a node that you have already visited before on this <strong>same</strong> process.</li>
</ul>
<p>Return <em>an array </em><code>answer</code><em> where </em><code>answer[i]</code><em> is the number of <strong>different</strong> nodes that you will visit if you perform the process starting from node </em><code>i</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaphdrawio-1.png" />
<pre>
<strong>Input:</strong> edges = [1,2,0,0]
<strong>Output:</strong> [3,3,3,4]
<strong>Explanation:</strong> We perform the process starting from each node in the following way:
- Starting from node 0, we visit the nodes 0 -&gt; 1 -&gt; 2 -&gt; 0. The number of different nodes we visit is 3.
- Starting from node 1, we visit the nodes 1 -&gt; 2 -&gt; 0 -&gt; 1. The number of different nodes we visit is 3.
- Starting from node 2, we visit the nodes 2 -&gt; 0 -&gt; 1 -&gt; 2. The number of different nodes we visit is 3.
- Starting from node 3, we visit the nodes 3 -&gt; 0 -&gt; 1 -&gt; 2 -&gt; 0. The number of different nodes we visit is 4.
</pre>
<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/31/graaph2drawio.png" style="width: 191px; height: 251px;" />
<pre>
<strong>Input:</strong> edges = [1,2,3,4,0]
<strong>Output:</strong> [5,5,5,5,5]
<strong>Explanation:</strong> Starting from any node we can visit every node in the graph in the process.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == edges.length</code></li>
<li><code>2 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= edges[i] &lt;= n - 1</code></li>
<li><code>edges[i] != i</code></li>
</ul>

View File

@ -0,0 +1,30 @@
<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>
<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>student_data:<strong>
</strong><code>[
[1, 15],
[2, 11],
[3, 11],
[4, 20]
]</code>
<strong>Output:</strong>
+------------+-----+
| student_id | age |
+------------+-----+
| 1 | 15 |
| 2 | 11 |
| 3 | 11 |
| 4 | 20 |
+------------+-----+
<strong>Explanation:</strong>
A DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.
</pre>

View File

@ -0,0 +1,45 @@
<pre>
DataFrame <code>employees</code>
+-------------+--------+
| Column Name | Type. |
+-------------+--------+
| name | object |
| salary | int. |
+-------------+--------+
</pre>
<p>A&nbsp;company plans to provide its employees with a bonus.</p>
<p>Write a solution to create a new column name <code>bonus</code> that contains the <strong>doubled values</strong> of the <code>salary</code> column.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong>
DataFrame employees
+---------+--------+
| name | salary |
+---------+--------+
| Piper | 4548 |
| Grace | 28150 |
| Georgia | 1103 |
| Willow | 6593 |
| Finn | 74576 |
| Thomas | 24433 |
+---------+--------+
<strong>Output:</strong>
+---------+--------+--------+
| name | salary | bonus |
+---------+--------+--------+
| Piper | 4548 | 9096 |
| Grace | 28150 | 56300 |
| Georgia | 1103 | 2206 |
| Willow | 593 | 13186 |
| Finn | 74576 | 149152 |
| Thomas | 24433 | 48866 |
+---------+--------+--------+
<strong>Explanation:</strong>
A new column bonus is created by doubling the value in the column salary.</pre>

View File

@ -0,0 +1,40 @@
<pre>
DataFrame: <code>employees</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| employee_id | int |
| name | object |
| department | object |
| salary | int |
+-------------+--------+
</pre>
<p>Write a solution to display the <strong>first <code>3</code> </strong>rows<strong> </strong>of this DataFrame.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>DataFrame employees
+-------------+-----------+-----------------------+--------+
| employee_id | name | department | salary |
+-------------+-----------+-----------------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
| 60 | Annabelle | InformationTechnology | 37678 |
| 49 | Jonathan | HumanResources | 23793 |
| 43 | Khaled | Administration | 40454 |
+-------------+-----------+-----------------------+--------+
<strong>Output:</strong>
+-------------+---------+-------------+--------+
| employee_id | name | department | salary |
+-------------+---------+-------------+--------+
| 3 | Bob | Operations | 48675 |
| 90 | Alice | Sales | 11096 |
| 9 | Tatiana | Engineering | 33805 |
+-------------+---------+-------------+--------+
<strong>Explanation:</strong>
Only the first 3 rows are displayed.</pre>

View File

@ -0,0 +1,44 @@
<pre>
DataFrame customers
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| customer_id | int |
| name | object |
| email | object |
+-------------+--------+
</pre>
<p>There are some duplicate rows in the DataFrame based on the <code>email</code> column.</p>
<p>Write a solution to remove these duplicate rows and keep only the <strong>first</strong> occurrence.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong class="example">Example 1:</strong>
<strong>Input:</strong>
+-------------+---------+---------------------+
| customer_id | name | email |
+-------------+---------+---------------------+
| 1 | Ella | emily@example.com |
| 2 | David | michael@example.com |
| 3 | Zachary | sarah@example.com |
| 4 | Alice | john@example.com |
| 5 | Finn | john@example.com |
| 6 | Violet | alice@example.com |
+-------------+---------+---------------------+
<strong>Output: </strong>
+-------------+---------+---------------------+
| customer_id | name | email |
+-------------+---------+---------------------+
| 1 | Ella | emily@example.com |
| 2 | David | michael@example.com |
| 3 | Zachary | sarah@example.com |
| 4 | Alice | john@example.com |
| 6 | Violet | alice@example.com |
+-------------+---------+---------------------+
<strong>Explanation:</strong>
Alic (customer_id = 4) and Finn (customer_id = 5) both use john@example.com, so only the first occurrence of this email is retained.
</pre>

View File

@ -0,0 +1,39 @@
<pre>
DataFrame students
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
+-------------+--------+
</pre>
<p>There are some rows having missing values in the <code>name</code> column.</p>
<p>Write a solution to remove the rows with missing values.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>+------------+-------+-----+
| student_id | name | age |
+------------+-------+-----+
| 32 | Piper | 5 |
| 217 | Grace | 19 |
| 779 | None | 20 |
| 849 | None | 14 |
+------------+-------+-----+
<strong>Output:
</strong>+------------+-------+-----+
| student_id | name | age |
+------------+-------+-----+
| 32 | Piper | 5 |
| 217 | Grace | 19 |
+------------+-------+-----+
<strong>Explanation:</strong>
Students with ids 779 and 849 have empty values in the name column, so they will be removed.</pre>

View File

@ -0,0 +1,37 @@
<pre>
DataFrame <code>products</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| quantity | int |
| price | int |
+-------------+--------+
</pre>
<p>Write a solution to fill in the missing value as <code><strong>0</strong></code> in the <code>quantity</code> column.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong class="example">Example 1:</strong>
<strong>Input:</strong>+-----------------+----------+-------+
| name | quantity | price |
+-----------------+----------+-------+
| Wristwatch | 32 | 135 |
| WirelessEarbuds | None | 821 |
| GolfClubs | None | 9319 |
| Printer | 849 | 3051 |
+-----------------+----------+-------+
<strong>Output:
</strong>+-----------------+----------+-------+
| name | quantity | price |
+-----------------+----------+-------+
| Wristwatch | 32 | 135 |
| WirelessEarbuds | 0 | 821 |
| GolfClubs | 0 | 9319 |
| Printer | 849 | 3051 |
+-----------------+----------+-------+
<strong>Explanation:</strong>
The quantity for Toaster and Headphones are filled by 0.</pre>

View File

@ -0,0 +1,45 @@
<pre>
DataFrame <code>players:</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| player_id | int |
| name | object |
| age | int |
| position | object |
| ... | ... |
+-------------+--------+
</pre>
<p>Write a solution to calculate and display the <strong>number of rows and columns</strong> of <code>players</code>.</p>
<p>Return the result as an array:</p>
<p><code>[number of rows, number of columns]</code></p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>+-----------+----------+-----+-------------+--------------------+
| player_id | name | age | position | team |
+-----------+----------+-----+-------------+--------------------+
| 846 | Mason | 21 | Forward | RealMadrid |
| 749 | Riley | 30 | Winger | Barcelona |
| 155 | Bob | 28 | Striker | ManchesterUnited |
| 583 | Isabella | 32 | Goalkeeper | Liverpool |
| 388 | Zachary | 24 | Midfielder | BayernMunich |
| 883 | Ava | 23 | Defender | Chelsea |
| 355 | Violet | 18 | Striker | Juventus |
| 247 | Thomas | 27 | Striker | ParisSaint-Germain |
| 761 | Jack | 33 | Midfielder | ManchesterCity |
| 642 | Charlie | 36 | Center-back | Arsenal |
+-----------+----------+-----+-------------+--------------------+<strong>
Output:
</strong>[10, 5]
<strong>Explanation:</strong>
This DataFrame contains 10 rows and 5 columns.
</pre>

View File

@ -0,0 +1,45 @@
<p>There is an undirected tree with <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. You are given the integer <code>n</code> and a 2D integer array <code>edges</code> of length <code>n - 1</code>, where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge between nodes <code>a<sub>i</sub></code> and <code>b<sub>i</sub></code> in the tree.</p>
<p>You are also given a <strong>0-indexed</strong> integer array <code>values</code> of length <code>n</code>, where <code>values[i]</code> is the <strong>value</strong> associated with the <code>i<sup>th</sup></code> node, and an integer <code>k</code>.</p>
<p>A <strong>valid split</strong> of the tree is obtained by removing any set of edges, possibly empty, from the tree such that the resulting components all have values that are divisible by <code>k</code>, where the <strong>value of a connected component</strong> is the sum of the values of its nodes.</p>
<p>Return <em>the <strong>maximum number of components</strong> in any valid split</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example12-cropped2svg.jpg" style="width: 1024px; height: 453px;" />
<pre>
<strong>Input:</strong> n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
<strong>Output:</strong> 2
<strong>Explanation:</strong> We remove the edge connecting node 1 with 2. The resulting split is valid because:
- The value of the component containing nodes 1 and 3 is values[1] + values[3] = 12.
- The value of the component containing nodes 0, 2, and 4 is values[0] + values[2] + values[4] = 6.
It can be shown that no other valid split has more than 2 connected components.</pre>
<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2023/08/07/example21svg-1.jpg" style="width: 999px; height: 338px;" />
<pre>
<strong>Input:</strong> n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
<strong>Output:</strong> 3
<strong>Explanation:</strong> We remove the edge connecting node 0 with 2, and the edge connecting node 0 with 1. The resulting split is valid because:
- The value of the component containing node 0 is values[0] = 3.
- The value of the component containing nodes 2, 5, and 6 is values[2] + values[5] + values[6] = 9.
- The value of the component containing nodes 1, 3, and 4 is values[1] + values[3] + values[4] = 6.
It can be shown that no other valid split has more than 3 connected components.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>edges.length == n - 1</code></li>
<li><code>edges[i].length == 2</code></li>
<li><code>0 &lt;= a<sub>i</sub>, b<sub>i</sub> &lt; n</code></li>
<li><code>values.length == n</code></li>
<li><code>0 &lt;= values[i] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>9</sup></code></li>
<li>Sum of <code>values</code> is divisible by <code>k</code>.</li>
<li>The input is generated such that <code>edges</code> represents a valid tree.</li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p>
<p>Return <em><strong>the maximum value over all triplets of indices</strong></em> <code>(i, j, k)</code> <em>such that</em> <code>i &lt; j &lt; k</code>. If all such triplets have a negative value, return <code>0</code>.</p>
<p>The <strong>value of a triplet of indices</strong> <code>(i, j, k)</code> is equal to <code>(nums[i] - nums[j]) * nums[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [12,6,1,2,7]
<strong>Output:</strong> 77
<strong>Explanation:</strong> The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,10,3,4,19]
<strong>Output:</strong> 133
<strong>Explanation:</strong> The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3]
<strong>Output:</strong> 0
<strong>Explanation:</strong> The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p>
<p>Return <em><strong>the maximum value over all triplets of indices</strong></em> <code>(i, j, k)</code> <em>such that</em> <code>i &lt; j &lt; k</code><em>. </em>If all such triplets have a negative value, return <code>0</code>.</p>
<p>The <strong>value of a triplet of indices</strong> <code>(i, j, k)</code> is equal to <code>(nums[i] - nums[j]) * nums[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [12,6,1,2,7]
<strong>Output:</strong> 77
<strong>Explanation:</strong> The value of the triplet (0, 2, 4) is (nums[0] - nums[2]) * nums[4] = 77.
It can be shown that there are no ordered triplets of indices with a value greater than 77.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,10,3,4,19]
<strong>Output:</strong> 133
<strong>Explanation:</strong> The value of the triplet (1, 2, 4) is (nums[1] - nums[2]) * nums[4] = 133.
It can be shown that there are no ordered triplets of indices with a value greater than 133.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3]
<strong>Output:</strong> 0
<strong>Explanation:</strong> The only ordered triplet of indices (0, 1, 2) has a negative value of (nums[0] - nums[1]) * nums[2] = -3. Hence, the answer would be 0.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,52 @@
<pre>
DataFrame <code>animals</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| species | object |
| age | int |
| weight | int |
+-------------+--------+
</pre>
<p>Write a solution to list the names of animals that weigh <strong>strictly more than</strong> <code>100</code> kilograms.</p>
<p>Return the&nbsp;animals sorted by weight in <strong>descending order</strong>.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong>
DataFrame animals:
+----------+---------+-----+--------+
| name | species | age | weight |
+----------+---------+-----+--------+
| Tatiana | Snake | 98 | 464 |
| Khaled | Giraffe | 50 | 41 |
| Alex | Leopard | 6 | 328 |
| Jonathan | Monkey | 45 | 463 |
| Stefan | Bear | 100 | 50 |
| Tommy | Panda | 26 | 349 |
+----------+---------+-----+--------+
<strong>Output:</strong>
+----------+
| name |
+----------+
| Tatiana |
| Jonathan |
| Tommy |
| Alex |
+----------+
<strong>Explanation:</strong>
All animals weighing more than 100 should be included in the results table.
Tatiana&#39;s weight is 464, Jonathan&#39;s weight is 463, Tommy&#39;s weight is 349, and Alex&#39;s weight is 328.
The results should be sorted in descending order of weight.</pre>
<p>&nbsp;</p>
<p>In Pandas, <strong>method chaining</strong> enables us to&nbsp;perform operations on a DataFrame without breaking up each operation into a separate line or creating multiple temporary variables.&nbsp;</p>
<p>Can you complete this&nbsp;task in just <strong>one line </strong>of code using method chaining?</p>

View File

@ -0,0 +1,40 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of positive integers.</p>
<p>There are two types of operations that you can apply on the array <strong>any</strong> number of times:</p>
<ul>
<li>Choose <strong>two</strong> elements with <strong>equal</strong> values and <strong>delete</strong> them from the array.</li>
<li>Choose <strong>three</strong> elements with <strong>equal</strong> values and <strong>delete</strong> them from the array.</li>
</ul>
<p>Return <em>the <strong>minimum</strong> number of operations required to make the array empty, or </em><code>-1</code><em> if it is not possible</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,3,3,2,2,4,2,3,4]
<strong>Output:</strong> 4
<strong>Explanation:</strong> We can apply the following operations to make the array empty:
- Apply the first operation on the elements at indices 0 and 3. The resulting array is nums = [3,3,2,4,2,3,4].
- Apply the first operation on the elements at indices 2 and 4. The resulting array is nums = [3,3,4,3,4].
- Apply the second operation on the elements at indices 0, 1, and 3. The resulting array is nums = [4,4].
- Apply the first operation on the elements at indices 0 and 1. The resulting array is nums = [].
It can be shown that we cannot make the array empty in less than 4 operations.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,1,2,2,3,3]
<strong>Output:</strong> -1
<strong>Explanation:</strong> It is impossible to empty the array.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>

View File

@ -0,0 +1,40 @@
<p>You are given an array <code>nums</code> of positive integers and an integer <code>k</code>.</p>
<p>In one operation, you can remove the last element of the array and add it to your collection.</p>
<p>Return <em>the <strong>minimum number of operations</strong> needed to collect elements</em> <code>1, 2, ..., k</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,1,5,4,2], k = 2
<strong>Output:</strong> 4
<strong>Explanation:</strong> After 4 operations, we collect elements 2, 4, 5, and 1, in this order. Our collection contains elements 1 and 2. Hence, the answer is 4.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,1,5,4,2], k = 5
<strong>Output:</strong> 5
<strong>Explanation:</strong> After 5 operations, we collect elements 2, 4, 5, 1, and 3, in this order. Our collection contains elements 1 through 5. Hence, the answer is 5.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [3,2,5,3,1], k = 3
<strong>Output:</strong> 4
<strong>Explanation:</strong> After 4 operations, we collect elements 1, 3, 5, and 2, in this order. Our collection contains elements 1 through 3. Hence, the answer is 4.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
<li><code>1 &lt;= nums[i] &lt;= nums.length</code></li>
<li><code>1 &lt;= k &lt;= nums.length</code></li>
<li>The input is generated such that you can collect elements <code>1, 2, ..., k</code>.</li>
</ul>

View File

@ -0,0 +1,44 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> and an integer <code>target</code>.</p>
<p>A <strong>0-indexed</strong> array <code>infinite_nums</code> is generated by infinitely appending the elements of <code>nums</code> to itself.</p>
<p>Return <em>the length of the <strong>shortest</strong> subarray of the array </em><code>infinite_nums</code><em> with a sum equal to </em><code>target</code><em>.</em> If there is no such subarray return <code>-1</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,2,3], target = 5
<strong>Output:</strong> 2
<strong>Explanation:</strong> In this example infinite_nums = [1,2,3,1,2,3,1,2,...].
The subarray in the range [1,2], has the sum equal to target = 5 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 5.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,1,1,2,3], target = 4
<strong>Output:</strong> 2
<strong>Explanation:</strong> In this example infinite_nums = [1,1,1,2,3,1,1,1,2,3,1,1,...].
The subarray in the range [4,5], has the sum equal to target = 4 and length = 2.
It can be proven that 2 is the shortest length of a subarray with sum equal to target = 4.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,4,6,8], target = 3
<strong>Output:</strong> -1
<strong>Explanation:</strong> In this example infinite_nums = [2,4,6,8,2,4,6,8,...].
It can be proven that there is no subarray with sum equal to target = 3.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,41 @@
<pre>
DataFrame <code>employees</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| salary | int |
+-------------+--------+
</pre>
<p>A company intends to give its employees a pay rise.</p>
<p>Write a solution to <strong>modify</strong> the <code>salary</code> column by multiplying each salary by 2.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>DataFrame employees
+---------+--------+
| name | salary |
+---------+--------+
| Jack | 19666 |
| Piper | 74754 |
| Mia | 62509 |
| Ulysses | 54866 |
+---------+--------+
<strong>Output:
</strong>+---------+--------+
| name | salary |
+---------+--------+
| Jack | 39332 |
| Piper | 149508 |
| Mia | 125018 |
| Ulysses | 109732 |
+---------+--------+
<strong>Explanation:
</strong>Every salary has been doubled.</pre>

View File

@ -0,0 +1,48 @@
<pre>
DataFrame <code>students</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| id | int |
| first | object |
| last | object |
| age | int |
+-------------+--------+
</pre>
<p>Write a solution to rename the columns as follows:</p>
<ul>
<li><code>id</code> to <code>student_id</code></li>
<li><code>first</code> to <code>first_name</code></li>
<li><code>last</code> to <code>last_name</code></li>
<li><code>age</code> to <code>age_in_years</code></li>
</ul>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong class="example">Example 1:</strong>
<strong>Input:
</strong>+----+---------+----------+-----+
| id | first | last | age |
+----+---------+----------+-----+
| 1 | Mason | King | 6 |
| 2 | Ava | Wright | 7 |
| 3 | Taylor | Hall | 16 |
| 4 | Georgia | Thompson | 18 |
| 5 | Thomas | Moore | 10 |
+----+---------+----------+-----+
<strong>Output:</strong>
+------------+------------+-----------+--------------+
| student_id | first_name | last_name | age_in_years |
+------------+------------+-----------+--------------+
| 1 | Mason | King | 6 |
| 2 | Ava | Wright | 7 |
| 3 | Taylor | Hall | 16 |
| 4 | Georgia | Thompson | 18 |
| 5 | Thomas | Moore | 10 |
+------------+------------+-----------+--------------+
<strong>Explanation:</strong>
The column names are changed accordingly.</pre>

View File

@ -0,0 +1,59 @@
<pre>
DataFrame <code>df1</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
+-------------+--------+
DataFrame <code>df2</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
+-------------+--------+
</pre>
<p>Write a solution to concatenate these two DataFrames <strong>vertically</strong> into one DataFrame.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
df1</strong>
+------------+---------+-----+
| student_id | name | age |
+------------+---------+-----+
| 1 | Mason | 8 |
| 2 | Ava | 6 |
| 3 | Taylor | 15 |
| 4 | Georgia | 17 |
+------------+---------+-----+
<strong>df2
</strong>+------------+------+-----+
| student_id | name | age |
+------------+------+-----+
| 5 | Leo | 7 |
| 6 | Alex | 7 |
+------------+------+-----+
<strong>Output:</strong>
+------------+---------+-----+
| student_id | name | age |
+------------+---------+-----+
| 1 | Mason | 8 |
| 2 | Ava | 6 |
| 3 | Taylor | 15 |
| 4 | Georgia | 17 |
| 5 | Leo | 7 |
| 6 | Alex | 7 |
+------------+---------+-----+
<strong>Explanation:
</strong>The two DataFramess are stacked vertically, and their rows are combined.</pre>

View File

@ -0,0 +1,44 @@
<pre>
DataFrame <code>report</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| product | object |
| quarter_1 | int |
| quarter_2 | int |
| quarter_3 | int |
| quarter_4 | int |
+-------------+--------+
</pre>
<p>Write a solution to <strong>reshape</strong> the data so that each row represents sales data for a product in a specific quarter.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:
</strong>+-------------+-----------+-----------+-----------+-----------+
| product | quarter_1 | quarter_2 | quarter_3 | quarter_4 |
+-------------+-----------+-----------+-----------+-----------+
| Umbrella | 417 | 224 | 379 | 611 |
| SleepingBag | 800 | 936 | 93 | 875 |
+-------------+-----------+-----------+-----------+-----------+
<strong>Output:</strong>
+-------------+-----------+-------+
| product | quarter | sales |
+-------------+-----------+-------+
| Umbrella | quarter_1 | 417 |
| SleepingBag | quarter_1 | 800 |
| Umbrella | quarter_2 | 224 |
| SleepingBag | quarter_2 | 936 |
| Umbrella | quarter_3 | 379 |
| SleepingBag | quarter_3 | 93 |
| Umbrella | quarter_4 | 611 |
| SleepingBag | quarter_4 | 875 |
+-------------+-----------+-------+
<strong>Explanation:</strong>
The DataFrame is reshaped from wide to long format. Each row represents the sales of a product in a quarter.
</pre>

View File

@ -0,0 +1,45 @@
<pre>
DataFrame <code>weather</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| city | object |
| month | object |
| temperature | int |
+-------------+--------+
</pre>
<p>Write a solution to <strong>pivot</strong> the data so that each row represents temperatures for a specific month, and each city is a separate column.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong class="example">Example 1:</strong>
<strong>Input:</strong>
+--------------+----------+-------------+
| city | month | temperature |
+--------------+----------+-------------+
| Jacksonville | January | 13 |
| Jacksonville | February | 23 |
| Jacksonville | March | 38 |
| Jacksonville | April | 5 |
| Jacksonville | May | 34 |
| ElPaso | January | 20 |
| ElPaso | February | 6 |
| ElPaso | March | 26 |
| ElPaso | April | 2 |
| ElPaso | May | 43 |
+--------------+----------+-------------+
<strong>Output:</strong><code>
+----------+--------+--------------+
| month | ElPaso | Jacksonville |
+----------+--------+--------------+
| April | 2 | 5 |
| February | 6 | 23 |
| January | 20 | 13 |
| March | 26 | 38 |
| May | 43 | 34 |
+----------+--------+--------------+</code>
<strong>Explanation:
</strong>The table is pivoted, each column represents a city, and each row represents a specific month.</pre>

View File

@ -0,0 +1,36 @@
<pre>
DataFrame students
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
+-------------+--------+
</pre>
<p>Write a solution to select the name and age of the student with <code>student_id = 101</code>.</p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<pre>
<strong>Example 1:
Input:</strong>
+------------+---------+-----+
| student_id | name | age |
+------------+---------+-----+
| 101 | Ulysses | 13 |
| 53 | William | 10 |
| 128 | Henry | 6 |
| 3 | Henry | 11 |
+------------+---------+-----+
<strong>Output:</strong>
+---------+-----+
| name | age |
+---------+-----+
| Ulysses | 13 |
+---------+-----+
<strong>Explanation:
</strong>Student Ulysses has student_id = 101, we select the name and age.</pre>

View File

@ -0,0 +1,45 @@
<p>You are given an array <code>nums</code> consisting of <strong>non-negative</strong> integers.</p>
<p>We define the score of subarray <code>nums[l..r]</code> such that <code>l &lt;= r</code> as <code>nums[l] AND nums[l + 1] AND ... AND nums[r]</code> where <strong>AND</strong> is the bitwise <code>AND</code> operation.</p>
<p>Consider splitting the array into one or more subarrays such that the following conditions are satisfied:</p>
<ul>
<li><strong>E</strong><strong>ach</strong> element of the array belongs to <strong>exactly</strong> one subarray.</li>
<li>The sum of scores of the subarrays is the <strong>minimum</strong> possible.</li>
</ul>
<p>Return <em>the <strong>maximum</strong> number of subarrays in a split that satisfies the conditions above.</em></p>
<p>A <strong>subarray</strong> is a contiguous part of an array.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,0,2,0,1,2]
<strong>Output:</strong> 3
<strong>Explanation:</strong> We can split the array into the following subarrays:
- [1,0]. The score of this subarray is 1 AND 0 = 0.
- [2,0]. The score of this subarray is 2 AND 0 = 0.
- [1,2]. The score of this subarray is 1 AND 2 = 0.
The sum of scores is 0 + 0 + 0 = 0, which is the minimum possible score that we can obtain.
It can be shown that we cannot split the array into more than 3 subarrays with a total score of 0. So we return 3.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [5,7,1,3]
<strong>Output:</strong> 1
<strong>Explanation:</strong> We can split the array into one subarray: [5,7,1,3] with a score of 1, which is the minimum possible score that we can obtain.
It can be shown that we cannot split the array into more than 1 subarray with a total score of 1. So we return 1.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
</ul>