diff --git a/solution/0200-0299/0277.Find the Celebrity/README.md b/solution/0200-0299/0277.Find the Celebrity/README.md
index 8ae7e2cf70159..43cfdc769a2ec 100644
--- a/solution/0200-0299/0277.Find the Celebrity/README.md
+++ b/solution/0200-0299/0277.Find the Celebrity/README.md
@@ -22,9 +22,11 @@ tags:
现在你想要确认这个 “名人” 是谁,或者确定这里没有 “名人”。而你唯一能做的就是问诸如 “A 你好呀,请问你认不认识 B呀?” 的问题,以确定 A 是否认识 B。你需要在(渐近意义上)尽可能少的问题内来确定这位 “名人” 是谁(或者确定这里没有 “名人”)。
-在本题中,你可以使用辅助函数 bool knows(a, b)
获取到 A 是否认识 B。请你来实现一个函数 int findCelebrity(n)
。
+给定整数 n
和一个辅助函数 bool knows(a, b)
用来获取 a
是否认识 b
。实现一个函数 int findCelebrity(n)
。派对最多只会有一个 “名人” 参加。
-派对最多只会有一个 “名人” 参加。若 “名人” 存在,请返回他/她的编号;若 “名人” 不存在,请返回 -1
。
+若 “名人” 存在,请返回他/她的编号;若 “名人” 不存在,请返回 -1
。
+
+注意 n x n
的二维数组 graph
给定的输入并不是 直接 提供给你的,而是 只能 通过辅助函数 knows
获取。graph[i][j] == 1
表示 i
认识 j
,而 graph[i][j] == 0
表示 j
不认识 i
。
diff --git a/solution/3300-3399/3368.First Letter Capitalization/README.md b/solution/3300-3399/3368.First Letter Capitalization/README.md
index 90ae5b8f17cb7..f0f5e92a89a2d 100644
--- a/solution/3300-3399/3368.First Letter Capitalization/README.md
+++ b/solution/3300-3399/3368.First Letter Capitalization/README.md
@@ -56,7 +56,7 @@ content_id 是这张表的唯一主键。
+------------+-----------------------------------+
| content_id | content_text |
+------------+-----------------------------------+
-| 1 | hello world of SQL |
+| 1 | hello world of Sql |
| 2 | the QUICK brown fox |
| 3 | data science AND machine learning |
| 4 | TOP rated programming BOOKS |
@@ -69,7 +69,7 @@ content_id 是这张表的唯一主键。
+------------+-----------------------------------+-----------------------------------+
| content_id | original_text | converted_text |
+------------+-----------------------------------+-----------------------------------+
-| 1 | hello world of SQL | Hello World Of SQL |
+| 1 | hello world of Sql | Hello World Of Sql |
| 2 | the QUICK brown fox | The Quick Brown Fox |
| 3 | data science AND machine learning | Data Science And Machine Learning |
| 4 | TOP rated programming BOOKS | Top Rated Programming Books |
@@ -81,7 +81,7 @@ content_id 是这张表的唯一主键。
- 对于 content_id = 1:
- - 每个单词的首字母都已经大写:Hello World Of SQL
+ - 每个单词的首字母都已经大写:Hello World Of Sql
- 对于 content_id = 2:
diff --git a/solution/3300-3399/3374.First Letter Capitalization II/README.md b/solution/3300-3399/3374.First Letter Capitalization II/README.md
new file mode 100644
index 0000000000000..27f0abfe0b9a9
--- /dev/null
+++ b/solution/3300-3399/3374.First Letter Capitalization II/README.md
@@ -0,0 +1,147 @@
+---
+comments: true
+difficulty: 困难
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md
+tags:
+ - 数据库
+---
+
+
+
+# [3374. 首字母大写 II](https://leetcode.cn/problems/first-letter-capitalization-ii)
+
+[English Version](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md)
+
+## 题目描述
+
+
+
+
表:user_content
+
+
++-------------+---------+
+| Column Name | Type |
++-------------+---------+
+| content_id | int |
+| content_text| varchar |
++-------------+---------+
+content_id 是这张表的唯一主键。
+每一行包含一个不同的 ID 以及对应的文本内容。
+
+
+编写一个解决方案来根据下面的规则来转换 content_text
列中的文本:
+
+
+ - 将每个单词的 第一个字母 转换为 大写,其余字母 保持小写。
+ - 特殊处理包含特殊字符的单词:
+
+ - 对于用短横
-
连接的词语,两个部份 都应该 大写(例如,top-rated → Top-Rated)
+
+
+ - 所有其他 格式 和 空格 应保持 不变
+
+
+返回结果表同时包含原始的 content_text
以及根据上述规则修改后的文本。
+
+结果格式如下例所示。
+
+
+
+示例:
+
+
+
输入:
+
+
user_content 表:
+
+
++------------+---------------------------------+
+| content_id | content_text |
++------------+---------------------------------+
+| 1 | hello world of SQL |
+| 2 | the QUICK-brown fox |
+| 3 | modern-day DATA science |
+| 4 | web-based FRONT-end development |
++------------+---------------------------------+
+
+
+
输出:
+
+
++------------+---------------------------------+---------------------------------+
+| content_id | original_text | converted_text |
++------------+---------------------------------+---------------------------------+
+| 1 | hello world of SQL | Hello World Of Sql |
+| 2 | the QUICK-brown fox | The Quick-Brown Fox |
+| 3 | modern-day DATA science | Modern-Day Data Science |
+| 4 | web-based FRONT-end development | Web-Based Front-End Development |
++------------+---------------------------------+---------------------------------+
+
+
+
解释:
+
+
+ - 对于 content_id = 1:
+
+ - 每个单词的首字母都是大写的:"Hello World Of Sql"
+
+
+ - 对于 content_id = 2:
+
+ - 包含的连字符词 "QUICK-brown" 变为 "Quick-Brown"
+ - 其它单词遵循普通的首字母大写规则
+
+
+ - 对于 content_id = 3:
+
+ - 连字符词 "modern-day" 变为 "Modern-Day"
+ - "DATA" 转换为 "Data"
+
+
+ - 对于 content_id = 4:
+
+ - 包含两个连字符词:"web-based" → "Web-Based"
+ - 以及 "FRONT-end" → "Front-End"
+
+
+
+
+
+
+
+## 解法
+
+
+
+### 方法一
+
+
+
+#### Pandas
+
+```python
+import pandas as pd
+
+
+def capitalize_content(user_content: pd.DataFrame) -> pd.DataFrame:
+ def convert_text(text: str) -> str:
+ return " ".join(
+ (
+ "-".join([part.capitalize() for part in word.split("-")])
+ if "-" in word
+ else word.capitalize()
+ )
+ for word in text.split(" ")
+ )
+
+ user_content["converted_text"] = user_content["content_text"].apply(convert_text)
+ return user_content.rename(columns={"content_text": "original_text"})[
+ ["content_id", "original_text", "converted_text"]
+ ]
+```
+
+
+
+
+
+
diff --git a/solution/3300-3399/3374.First Letter Capitalization II/README_EN.md b/solution/3300-3399/3374.First Letter Capitalization II/README_EN.md
new file mode 100644
index 0000000000000..33398814f88f9
--- /dev/null
+++ b/solution/3300-3399/3374.First Letter Capitalization II/README_EN.md
@@ -0,0 +1,146 @@
+---
+comments: true
+difficulty: Hard
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md
+tags:
+ - Database
+---
+
+
+
+# [3374. First Letter Capitalization II](https://leetcode.com/problems/first-letter-capitalization-ii)
+
+[中文文档](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md)
+
+## Description
+
+
+
+Table: user_content
+
+
++-------------+---------+
+| Column Name | Type |
++-------------+---------+
+| content_id | int |
+| content_text| varchar |
++-------------+---------+
+content_id is the unique key for this table.
+Each row contains a unique ID and the corresponding text content.
+
+
+Write a solution to transform the text in the content_text
column by applying the following rules:
+
+
+ - Convert the first letter of each word to uppercase and the remaining letters to lowercase
+ - Special handling for words containing special characters:
+
+ - For words connected with a hyphen
-
, both parts should be capitalized (e.g., top-rated → Top-Rated)
+
+
+ - All other formatting and spacing should remain unchanged
+
+
+Return the result table that includes both the original content_text
and the modified text following the above rules.
+
+The result format is in the following example.
+
+
+Example:
+
+
+
Input:
+
+
user_content table:
+
+
++------------+---------------------------------+
+| content_id | content_text |
++------------+---------------------------------+
+| 1 | hello world of SQL |
+| 2 | the QUICK-brown fox |
+| 3 | modern-day DATA science |
+| 4 | web-based FRONT-end development |
++------------+---------------------------------+
+
+
+
Output:
+
+
++------------+---------------------------------+---------------------------------+
+| content_id | original_text | converted_text |
++------------+---------------------------------+---------------------------------+
+| 1 | hello world of SQL | Hello World Of Sql |
+| 2 | the QUICK-brown fox | The Quick-Brown Fox |
+| 3 | modern-day DATA science | Modern-Day Data Science |
+| 4 | web-based FRONT-end development | Web-Based Front-End Development |
++------------+---------------------------------+---------------------------------+
+
+
+
Explanation:
+
+
+ - For content_id = 1:
+
+ - Each word's first letter is capitalized: "Hello World Of Sql"
+
+
+ - For content_id = 2:
+
+ - Contains the hyphenated word "QUICK-brown" which becomes "Quick-Brown"
+ - Other words follow normal capitalization rules
+
+
+ - For content_id = 3:
+
+ - Hyphenated word "modern-day" becomes "Modern-Day"
+ - "DATA" is converted to "Data"
+
+
+ - For content_id = 4:
+
+ - Contains two hyphenated words: "web-based" → "Web-Based"
+ - And "FRONT-end" → "Front-End"
+
+
+
+
+
+
+
+## Solutions
+
+
+
+### Solution 1
+
+
+
+#### Pandas
+
+```python
+import pandas as pd
+
+
+def capitalize_content(user_content: pd.DataFrame) -> pd.DataFrame:
+ def convert_text(text: str) -> str:
+ return " ".join(
+ (
+ "-".join([part.capitalize() for part in word.split("-")])
+ if "-" in word
+ else word.capitalize()
+ )
+ for word in text.split(" ")
+ )
+
+ user_content["converted_text"] = user_content["content_text"].apply(convert_text)
+ return user_content.rename(columns={"content_text": "original_text"})[
+ ["content_id", "original_text", "converted_text"]
+ ]
+```
+
+
+
+
+
+
diff --git a/solution/3300-3399/3374.First Letter Capitalization II/Solution.py b/solution/3300-3399/3374.First Letter Capitalization II/Solution.py
new file mode 100644
index 0000000000000..48bca9b3fcadf
--- /dev/null
+++ b/solution/3300-3399/3374.First Letter Capitalization II/Solution.py
@@ -0,0 +1,18 @@
+import pandas as pd
+
+
+def capitalize_content(user_content: pd.DataFrame) -> pd.DataFrame:
+ def convert_text(text: str) -> str:
+ return " ".join(
+ (
+ "-".join([part.capitalize() for part in word.split("-")])
+ if "-" in word
+ else word.capitalize()
+ )
+ for word in text.split(" ")
+ )
+
+ user_content["converted_text"] = user_content["content_text"].apply(convert_text)
+ return user_content.rename(columns={"content_text": "original_text"})[
+ ["content_id", "original_text", "converted_text"]
+ ]
diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md
index 3200ddda0ecbe..d31563ff0c7bb 100644
--- a/solution/DATABASE_README.md
+++ b/solution/DATABASE_README.md
@@ -302,6 +302,7 @@
| 3338 | [第二高的薪水 II](/solution/3300-3399/3338.Second%20Highest%20Salary%20II/README.md) | `数据库` | 中等 | 🔒 |
| 3358 | [评分为 NULL 的图书](/solution/3300-3399/3358.Books%20with%20NULL%20Ratings/README.md) | `数据库` | 简单 | 🔒 |
| 3368 | [首字母大写](/solution/3300-3399/3368.First%20Letter%20Capitalization/README.md) | | 困难 | 🔒 |
+| 3374 | [首字母大写 II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md) | | 困难 | |
## 版权
diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md
index 7b04bc89db897..9c84166e26edd 100644
--- a/solution/DATABASE_README_EN.md
+++ b/solution/DATABASE_README_EN.md
@@ -300,6 +300,7 @@ Press Control + F(or Command + F on
| 3338 | [Second Highest Salary II](/solution/3300-3399/3338.Second%20Highest%20Salary%20II/README_EN.md) | `Database` | Medium | 🔒 |
| 3358 | [Books with NULL Ratings](/solution/3300-3399/3358.Books%20with%20NULL%20Ratings/README_EN.md) | `Database` | Easy | 🔒 |
| 3368 | [First Letter Capitalization](/solution/3300-3399/3368.First%20Letter%20Capitalization/README_EN.md) | | Hard | 🔒 |
+| 3374 | [First Letter Capitalization II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md) | | Hard | |
## Copyright
diff --git a/solution/README.md b/solution/README.md
index b0f3ac4d16607..edc651471aafc 100644
--- a/solution/README.md
+++ b/solution/README.md
@@ -3383,6 +3383,7 @@
| 3371 | [识别数组中的最大异常值](/solution/3300-3399/3371.Identify%20the%20Largest%20Outlier%20in%20an%20Array/README.md) | | 中等 | 第 426 场周赛 |
| 3372 | [连接两棵树后最大目标节点数目 I](/solution/3300-3399/3372.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20I/README.md) | | 中等 | 第 426 场周赛 |
| 3373 | [连接两棵树后最大目标节点数目 II](/solution/3300-3399/3373.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20II/README.md) | | 困难 | 第 426 场周赛 |
+| 3374 | [首字母大写 II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md) | | 困难 | |
## 版权
diff --git a/solution/README_EN.md b/solution/README_EN.md
index 62b565217e8cf..f46cc766ff512 100644
--- a/solution/README_EN.md
+++ b/solution/README_EN.md
@@ -3381,6 +3381,7 @@ Press Control + F(or Command + F on
| 3371 | [Identify the Largest Outlier in an Array](/solution/3300-3399/3371.Identify%20the%20Largest%20Outlier%20in%20an%20Array/README_EN.md) | | Medium | Weekly Contest 426 |
| 3372 | [Maximize the Number of Target Nodes After Connecting Trees I](/solution/3300-3399/3372.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20I/README_EN.md) | | Medium | Weekly Contest 426 |
| 3373 | [Maximize the Number of Target Nodes After Connecting Trees II](/solution/3300-3399/3373.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20II/README_EN.md) | | Hard | Weekly Contest 426 |
+| 3374 | [First Letter Capitalization II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md) | | Hard | |
## Copyright