diff --git a/README.md b/README.md index 912b9a2..f804933 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Useful for preparing for technical interviews and improving your SQL skills. - [3475. DNA Pattern Recognition](./leetcode/medium/3475.%20DNA%20Pattern%20Recognition.sql) 3. [Hard](./leetcode/hard/) - [185. Department Top Three Salaries](./leetcode/hard/185.%20Department%20Top%20Three%20Salaries.sql) + - [3374. First Letter Capitalization II](./leetcode/hard/3374.%20First%20Letter%20Capitalization%20II.sql) ## Contributing diff --git a/leetcode/hard/3374. First Letter Capitalization II.sql b/leetcode/hard/3374. First Letter Capitalization II.sql new file mode 100644 index 0000000..2303ede --- /dev/null +++ b/leetcode/hard/3374. First Letter Capitalization II.sql @@ -0,0 +1,30 @@ +/* +Question 3374. First Letter Capitalization II +Link: https://leetcode.com/problems/first-letter-capitalization-ii/description/?envType=problem-list-v2&envId=database + +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 easiest solution :) + +SELECT + content_id, + content_text AS original_text, + INITCAP(content_text) AS converted_text +FROM user_content