1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-24 22:38:57 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -7,17 +7,17 @@
"boundTopicId": 3007045,
"title": "First Letter Capitalization II",
"titleSlug": "first-letter-capitalization-ii",
"content": "<p>Table: <code>user_content</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| content_id | int |\n| content_text| varchar |\n+-------------+---------+\ncontent_id is the unique key for this table.\nEach row contains a unique ID and the corresponding text content.\n</pre>\n\n<p>Write a solution to transform the text in the <code>content_text</code> column by applying the following rules:</p>\n\n<ul>\n\t<li>Convert the <strong>first letter</strong> of each word to <strong>uppercase</strong> and the <strong>remaining</strong> letters to <strong>lowercase</strong></li>\n\t<li>Special handling for words containing special characters:\n\t<ul>\n\t\t<li>For words connected with a hyphen <code>-</code>, <strong>both parts</strong> should be <strong>capitalized</strong> (<strong>e.g.</strong>, top-rated&nbsp;&rarr; Top-Rated)</li>\n\t</ul>\n\t</li>\n\t<li>All other <strong>formatting</strong> and <strong>spacing</strong> should remain <strong>unchanged</strong></li>\n</ul>\n\n<p>Return <em>the result table that includes both the original <code>content_text</code> and the modified text following the above rules</em>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>Input:</strong></p>\n\n<p>user_content table:</p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+\n| content_id | content_text |\n+------------+---------------------------------+\n| 1 | hello world of SQL |\n| 2 | the QUICK-brown fox |\n| 3 | modern-day DATA science |\n| 4 | web-based FRONT-end development |\n+------------+---------------------------------+\n</pre>\n\n<p><strong>Output:</strong></p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+---------------------------------+\n| content_id | original_text | converted_text |\n+------------+---------------------------------+---------------------------------+\n| 1 | hello world of SQL | Hello World Of Sql |\n| 2 | the QUICK-brown fox | The Quick-Brown Fox |\n| 3 | modern-day DATA science | Modern-Day Data Science |\n| 4 | web-based FRONT-end development | Web-Based Front-End Development |\n+------------+---------------------------------+---------------------------------+\n</pre>\n\n<p><strong>Explanation:</strong></p>\n\n<ul>\n\t<li>For content_id = 1:\n\t<ul>\n\t\t<li>Each word&#39;s first letter is capitalized: &quot;Hello World Of Sql&quot;</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 2:\n\t<ul>\n\t\t<li>Contains the hyphenated word &quot;QUICK-brown&quot; which becomes &quot;Quick-Brown&quot;</li>\n\t\t<li>Other words follow normal capitalization rules</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 3:\n\t<ul>\n\t\t<li>Hyphenated word &quot;modern-day&quot; becomes &quot;Modern-Day&quot;</li>\n\t\t<li>&quot;DATA&quot; is converted to &quot;Data&quot;</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 4:\n\t<ul>\n\t\t<li>Contains two hyphenated words: &quot;web-based&quot; &rarr; &quot;Web-Based&quot;</li>\n\t\t<li>And &quot;FRONT-end&quot; &rarr; &quot;Front-End&quot;</li>\n\t</ul>\n\t</li>\n</ul>\n</div>\n",
"content": "<p>Table: <code>user_content</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| content_id | int |\n| content_text| varchar |\n+-------------+---------+\ncontent_id is the unique key for this table.\nEach row contains a unique ID and the corresponding text content.\n</pre>\n\n<p>Write a solution to transform the text in the <code>content_text</code> column by applying the following rules:</p>\n\n<ul>\n\t<li>Convert the <strong>first letter</strong> of each word to <strong>uppercase</strong> and the <strong>remaining</strong> letters to <strong>lowercase</strong></li>\n\t<li>Special handling for words containing special characters:\n\t<ul>\n\t\t<li>For words connected with a hyphen <code>-</code>, <strong>both parts</strong> should be <strong>capitalized</strong> (<strong>e.g.</strong>, top-rated&nbsp;&rarr; Top-Rated)</li>\n\t</ul>\n\t</li>\n\t<li>All other <strong>formatting</strong> and <strong>spacing</strong> should remain <strong>unchanged</strong></li>\n</ul>\n\n<p>Return <em>the result table that includes both the original <code>content_text</code> and the modified text following the above rules</em>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>Input:</strong></p>\n\n<p>user_content table:</p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+\n| content_id | content_text |\n+------------+---------------------------------+\n| 1 | hello world of SQL |\n| 2 | the QUICK-brown fox |\n| 3 | modern-day DATA science |\n| 4 | web-based FRONT-end development |\n+------------+---------------------------------+\n</pre>\n\n<p><strong>Output:</strong></p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+---------------------------------+\n| content_id | original_text | converted_text |\n+------------+---------------------------------+---------------------------------+\n| 1 | hello world of SQL | Hello World Of Sql |\n| 2 | the QUICK-brown fox | The Quick-Brown Fox |\n| 3 | modern-day DATA science | Modern-Day Data Science |\n| 4 | web-based FRONT-end development | Web-Based Front-End Development |\n+------------+---------------------------------+---------------------------------+\n</pre>\n\n<p><strong>Explanation:</strong></p>\n\n<ul>\n\t<li>For content_id = 1:\n\t<ul>\n\t\t<li>Each word&#39;s first letter is capitalized: &quot;Hello World Of Sql&quot;</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 2:\n\t<ul>\n\t\t<li>Contains the hyphenated word &quot;QUICK-brown&quot; which becomes &quot;Quick-Brown&quot;</li>\n\t\t<li>Other words follow normal capitalization rules</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 3:\n\t<ul>\n\t\t<li>Hyphenated word &quot;modern-day&quot; becomes &quot;Modern-Day&quot;</li>\n\t\t<li>&quot;DATA&quot; is converted to &quot;Data&quot;</li>\n\t</ul>\n\t</li>\n\t<li>For content_id = 4:\n\t<ul>\n\t\t<li>Contains two hyphenated words: &quot;web-based&quot; &rarr; &quot;Web-Based&quot;</li>\n\t\t<li>And &quot;FRONT-end&quot; &rarr; &quot;Front-End&quot;</li>\n\t</ul>\n\t</li>\n</ul>\n</div>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>context_text</code> contains only English letters, and the characters in the list <code>[&#39;\\&#39;, &#39; &#39;, &#39;@&#39;, &#39;-&#39;, &#39;/&#39;, &#39;^&#39;, &#39;,&#39;]</code></li>\n</ul>\n",
"translatedTitle": "首字母大写 II",
"translatedContent": "<p>表:<code>user_content</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| content_id | int |\n| content_text| varchar |\n+-------------+---------+\ncontent_id 是这张表的唯一主键。\n每一行包含一个不同的 ID 以及对应的文本内容。\n</pre>\n\n<p>编写一个解决方案来根据下面的规则来转换&nbsp;<code>content_text</code>&nbsp;列中的文本:</p>\n\n<ul>\n\t<li>将每个单词的 <strong>第一个字母</strong>&nbsp;转换为 <strong>大写</strong>,其余字母 <strong>保持小写</strong>。</li>\n\t<li>特殊处理包含特殊字符的单词:\n\t<ul>\n\t\t<li>对于用短横&nbsp;<code>-</code>&nbsp;连接的词语,<strong>两个部份</strong>&nbsp;都应该&nbsp;<strong>大写</strong><strong>例如</strong>top-rated&nbsp;→ Top-Rated</li>\n\t</ul>\n\t</li>\n\t<li>所有其他 <strong>格式</strong> 和 <strong>空格</strong> 应保持 <strong>不变</strong></li>\n</ul>\n\n<p>返回结果表同时包含原始的&nbsp;<code>content_text</code> 以及根据上述规则修改后的文本。</p>\n\n<p>结果格式如下例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>输入:</strong></p>\n\n<p>user_content 表:</p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+\n| content_id | content_text |\n+------------+---------------------------------+\n| 1 | hello world of SQL |\n| 2 | the QUICK-brown fox |\n| 3 | modern-day DATA science |\n| 4 | web-based FRONT-end development |\n+------------+---------------------------------+\n</pre>\n\n<p><strong>输出:</strong></p>\n\n<pre class=\"example-io\">\n+------------+---------------------------------+---------------------------------+\n| content_id | original_text | converted_text |\n+------------+---------------------------------+---------------------------------+\n| 1 | hello world of SQL | Hello World Of Sql |\n| 2 | the QUICK-brown fox | The Quick-Brown Fox |\n| 3 | modern-day DATA science | Modern-Day Data Science |\n| 4 | web-based FRONT-end development | Web-Based Front-End Development |\n+------------+---------------------------------+---------------------------------+\n</pre>\n\n<p><strong>解释:</strong></p>\n\n<ul>\n\t<li>对于 content_id = 1\n\t<ul>\n\t\t<li>每个单词的首字母都是大写的:\"Hello World Of Sql\"</li>\n\t</ul>\n\t</li>\n\t<li>对于 content_id = 2\n\t<ul>\n\t\t<li>包含的连字符词 \"QUICK-brown\" 变为 \"Quick-Brown\"</li>\n\t\t<li>其它单词遵循普通的首字母大写规则</li>\n\t</ul>\n\t</li>\n\t<li>对于 content_id = 3\n\t<ul>\n\t\t<li>连字符词 \"modern-day\" 变为 \"Modern-Day\"</li>\n\t\t<li>\"DATA\" 转换为 \"Data\"</li>\n\t</ul>\n\t</li>\n\t<li>对于 content_id = 4\n\t<ul>\n\t\t<li>包含两个连字符词:\"web-based\" → \"Web-Based\"</li>\n\t\t<li>以及 \"FRONT-end\" → \"Front-End\"</li>\n\t</ul>\n\t</li>\n</ul>\n</div>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 1,
"likes": 5,
"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, \"cangjie\": false}",
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python3\": false, \"python\": false, \"javascript\": false, \"typescript\": false, \"csharp\": false, \"c\": false, \"golang\": false, \"kotlin\": false, \"swift\": false, \"rust\": false, \"ruby\": false, \"php\": false, \"dart\": false, \"scala\": false, \"elixir\": false, \"erlang\": false, \"racket\": false, \"cangjie\": false, \"bash\": false, \"html\": false, \"pythonml\": false, \"react\": false, \"vanillajs\": false, \"mysql\": false, \"mssql\": false, \"postgresql\": false, \"oraclesql\": false, \"pythondata\": false}",
"topicTags": [
{
"name": "Database",
@@ -40,6 +40,12 @@
"code": "/* Write your T-SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
@@ -51,15 +57,9 @@
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef capitalize_content(user_content: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"243\", \"totalSubmission\": \"318\", \"totalAcceptedRaw\": 243, \"totalSubmissionRaw\": 318, \"acRate\": \"76.4%\"}",
"stats": "{\"totalAccepted\": \"1.3K\", \"totalSubmission\": \"2.5K\", \"totalAcceptedRaw\": 1292, \"totalSubmissionRaw\": 2520, \"acRate\": \"51.3%\"}",
"hints": [],
"solution": null,
"status": null,