mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
93 lines
10 KiB
JSON
93 lines
10 KiB
JSON
{
|
||
"data": {
|
||
"question": {
|
||
"questionId": "585",
|
||
"questionFrontendId": "585",
|
||
"categoryTitle": "Database",
|
||
"boundTopicId": 2643,
|
||
"title": "Investments in 2016",
|
||
"titleSlug": "investments-in-2016",
|
||
"content": "<p>Table: <code>Insurance</code></p>\n\n<pre>\n+-------------+-------+\n| Column Name | Type |\n+-------------+-------+\n| pid | int |\n| tiv_2015 | float |\n| tiv_2016 | float |\n| lat | float |\n| lon | float |\n+-------------+-------+\npid is the primary key (column with unique values) for this table.\nEach row of this table contains information about one policy where:\npid is the policyholder's policy ID.\ntiv_2015 is the total investment value in 2015 and tiv_2016 is the total investment value in 2016.\nlat is the latitude of the policy holder's city. It's guaranteed that lat is not NULL.\nlon is the longitude of the policy holder's city. It's guaranteed that lon is not NULL.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to report the sum of all total investment values in 2016 <code>tiv_2016</code>, for all policyholders who:</p>\n\n<ul>\n\t<li>have the same <code>tiv_2015</code> value as one or more other policyholders, and</li>\n\t<li>are not located in the same city as any other policyholder (i.e., the (<code>lat, lon</code>) attribute pairs must be unique).</li>\n</ul>\n\n<p>Round <code>tiv_2016</code> to <strong>two decimal places</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nInsurance table:\n+-----+----------+----------+-----+-----+\n| pid | tiv_2015 | tiv_2016 | lat | lon |\n+-----+----------+----------+-----+-----+\n| 1 | 10 | 5 | 10 | 10 |\n| 2 | 20 | 20 | 20 | 20 |\n| 3 | 10 | 30 | 20 | 20 |\n| 4 | 10 | 40 | 40 | 40 |\n+-----+----------+----------+-----+-----+\n<strong>Output:</strong> \n+----------+\n| tiv_2016 |\n+----------+\n| 45.00 |\n+----------+\n<strong>Explanation:</strong> \nThe first record in the table, like the last record, meets both of the two criteria.\nThe tiv_2015 value 10 is the same as the third and fourth records, and its location is unique.\n\nThe second record does not meet any of the two criteria. Its tiv_2015 is not like any other policyholders and its location is the same as the third record, which makes the third record fail, too.\nSo, the result is the sum of tiv_2016 of the first and last record, which is 45.\n</pre>\n",
|
||
"translatedTitle": "2016年的投资",
|
||
"translatedContent": "<p><code>Insurance</code> 表:</p>\n\n<div class=\"original__bRMd\">\n<div>\n<pre>\n+-------------+-------+\n| Column Name | Type |\n+-------------+-------+\n| pid | int |\n| tiv_2015 | float |\n| tiv_2016 | float |\n| lat | float |\n| lon | float |\n+-------------+-------+\npid 是这张表的主键(具有唯一值的列)。\n表中的每一行都包含一条保险信息,其中:\npid 是投保人的投保编号。\ntiv_2015 是该投保人在 2015 年的总投保金额,tiv_2016 是该投保人在 2016 年的总投保金额。\nlat 是投保人所在城市的纬度。题目数据确保 lat 不为空。\nlon 是投保人所在城市的经度。题目数据确保 lon 不为空。</pre>\n\n<p> </p>\n\n<p>编写解决方案报告 2016 年 (<code>tiv_2016</code>) 所有满足下述条件的投保人的投保金额之和:</p>\n\n<ul>\n\t<li>他在 2015 年的投保额 (<code>tiv_2015</code>) 至少跟一个其他投保人在 2015 年的投保额相同。</li>\n\t<li>他所在的城市必须与其他投保人都不同(也就是说 (<code>lat, lon</code>) 不能跟其他任何一个投保人完全相同)。</li>\n</ul>\n\n<p><code>tiv_2016</code> 四舍五入的 <strong>两位小数</strong> 。</p>\n\n<p>查询结果格式如下例所示。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>\nInsurance 表:\n+-----+----------+----------+-----+-----+\n| pid | tiv_2015 | tiv_2016 | lat | lon |\n+-----+----------+----------+-----+-----+\n| 1 | 10 | 5 | 10 | 10 |\n| 2 | 20 | 20 | 20 | 20 |\n| 3 | 10 | 30 | 20 | 20 |\n| 4 | 10 | 40 | 40 | 40 |\n+-----+----------+----------+-----+-----+\n<strong>输出:</strong>\n+----------+\n| tiv_2016 |\n+----------+\n| 45.00 |\n+----------+\n<strong>解释:\n</strong>表中的第一条记录和最后一条记录都满足两个条件。\ntiv_2015 值为 10 与第三条和第四条记录相同,且其位置是唯一的。\n\n第二条记录不符合任何一个条件。其 tiv_2015 与其他投保人不同,并且位置与第三条记录相同,这也导致了第三条记录不符合题目要求。\n因此,结果是第一条记录和最后一条记录的 tiv_2016 之和,即 45 。</pre>\n</div>\n</div>\n",
|
||
"isPaidOnly": false,
|
||
"difficulty": "Medium",
|
||
"likes": 112,
|
||
"dislikes": 0,
|
||
"isLiked": null,
|
||
"similarQuestions": "[]",
|
||
"contributors": [],
|
||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
|
||
"topicTags": [
|
||
{
|
||
"name": "Database",
|
||
"slug": "database",
|
||
"translatedName": "数据库",
|
||
"__typename": "TopicTagNode"
|
||
}
|
||
],
|
||
"companyTagStats": null,
|
||
"codeSnippets": [
|
||
{
|
||
"lang": "MySQL",
|
||
"langSlug": "mysql",
|
||
"code": "# Write your MySQL query statement below",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "MS SQL Server",
|
||
"langSlug": "mssql",
|
||
"code": "/* Write your T-SQL query statement below */",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "Oracle",
|
||
"langSlug": "oraclesql",
|
||
"code": "/* Write your PL/SQL query statement below */",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "Pandas",
|
||
"langSlug": "pythondata",
|
||
"code": "import pandas as pd\n\ndef find_investments(insurance: pd.DataFrame) -> pd.DataFrame:\n ",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "PostgreSQL",
|
||
"langSlug": "postgresql",
|
||
"code": "-- Write your PostgreSQL query statement below",
|
||
"__typename": "CodeSnippetNode"
|
||
}
|
||
],
|
||
"stats": "{\"totalAccepted\": \"28.8K\", \"totalSubmission\": \"61.9K\", \"totalAcceptedRaw\": 28819, \"totalSubmissionRaw\": 61871, \"acRate\": \"46.6%\"}",
|
||
"hints": [
|
||
"Make the (LAT, LON) a pair to represent the location information"
|
||
],
|
||
"solution": null,
|
||
"status": null,
|
||
"sampleTestCase": "{\"headers\":{\"Insurance\":[\"pid\",\"tiv_2015\",\"tiv_2016\",\"lat\",\"lon\"]},\"rows\":{\"Insurance\":[[1,10,5,10,10],[2,20,20,20,20],[3,10,30,20,20],[4,10,40,40,40]]}}",
|
||
"metaData": "{\"mysql\":[\"Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"],\"mssql\":[\"Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"],\"oraclesql\":[\"Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"],\"database\":true,\"name\":\"find_investments\",\"pythondata\":[\"Insurance = pd.DataFrame([], columns=['pid', 'tiv_2015', 'tiv_2016', 'lat', 'lon']).astype({'pid':'Int64', 'tiv_2015':'Float64', 'tiv_2016':'Float64', 'lat':'Float64', 'lon':'Float64'})\"],\"postgresql\":[\"\\nCreate Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)\"],\"database_schema\":{\"Insurance\":{\"pid\":\"INT\",\"tiv_2015\":\"FLOAT\",\"tiv_2016\":\"FLOAT\",\"lat\":\"FLOAT\",\"lon\":\"FLOAT\"}}}",
|
||
"judgerAvailable": true,
|
||
"judgeType": "large",
|
||
"mysqlSchemas": [
|
||
"Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)",
|
||
"Truncate table Insurance",
|
||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('1', '10', '5', '10', '10')",
|
||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('2', '20', '20', '20', '20')",
|
||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('3', '10', '30', '20', '20')",
|
||
"insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('4', '10', '40', '40', '40')"
|
||
],
|
||
"enableRunCode": true,
|
||
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
|
||
"book": null,
|
||
"isSubscribed": false,
|
||
"isDailyQuestion": false,
|
||
"dailyRecordStatus": null,
|
||
"editorType": "CKEDITOR",
|
||
"ugcQuestionId": null,
|
||
"style": "LEETCODE",
|
||
"exampleTestcases": "{\"headers\":{\"Insurance\":[\"pid\",\"tiv_2015\",\"tiv_2016\",\"lat\",\"lon\"]},\"rows\":{\"Insurance\":[[1,10,5,10,10],[2,20,20,20,20],[3,10,30,20,20],[4,10,40,40,40]]}}",
|
||
"__typename": "QuestionNode"
|
||
}
|
||
}
|
||
} |