Compare commits

...

2 Commits

Author SHA1 Message Date
c396a84294 docs(logs): update monthly log 2025-09-12 13:37:31 +08:00
2d6209a043 [#3227] docs(leetcode): update README 2025-09-12 13:34:05 +08:00
2 changed files with 27 additions and 26 deletions

View File

@@ -17,6 +17,7 @@
|------|------|------|------|------|------|------|
| 09/08 | Convert Integer To The Sum Of Two No Zero Integers | Easy | C# | 0.2hr | Done | |
| 09/11 | Sort Vowels In A String | Medium | C# | 0.2hr | Done | |
| 09/11 | [3227]Vowels Game In A String | Medium | C#, go | 0.1hr | Done | like easy |
### Week 3
| 日期 | 題目 | 難度 | 語言 | 耗時 | 狀態 | 心得 |

View File

@@ -21,56 +21,56 @@ Return `true` if Alice wins the game, and `false` otherwise.
The English vowels are: `a`, `e`, `i`, `o`, and `u`.
## 先備條件與限制
- 輸入限制n ∈ [?, ?]、值域 ∈ [?, ?]
- 回傳/輸出格式:...
- 其他:是否允許排序/就地修改
- 輸入限制n ∈ [1, 10^5]、字符為小寫英文字母
- 回傳/輸出格式:boolean 值true 表示 Alice 獲勝
## 解題思路
### 初步分析
- 類型:雙指針 / 滑動視窗 / 排序 / DP / 貪心 / 圖論 ...
- 類型:博弈論 / 數學 / 腦筋急轉彎
- 關鍵觀察:
- 複雜度目標理由:
- Alice 先手,需移除含奇數個母音的子字串
- Bob 後手,需移除含偶數個母音的子字串
- 複雜度目標理由:只需檢查是否存在母音
### 解法比較
1. 解法A基準/暴力):
- 思路:
發現 Alice 獲勝條件極其簡單
- 正確性:
- 複雜度O(?) / O(?)
2. 解法B優化
- 思路:
- 正確性:
- 複雜度O(?) / O(?)
### 乾跑Dry Run
- 範例:...
只需檢查是否存在母音
- 複雜度O(n) / O(1)
### 常見陷阱
- 邊界:空/單一/極值/全相等
- 去重:排序後跳重複、集合
- 溢位:使用 64-bit
- 邊界:空字串(題目保證 n≥1、全母音、無母音
- 過度複雜化:誤以為需要複雜的博弈分析
- 計數錯誤:誤以為需要精確計算母音數量
- 大小寫:題目保證小寫字母
## 測試案例
### 範例輸入輸出
```
Input: ...
Output: ...
Explanation: ...
Input: s = "leetcode"
Output: true
Explanation: Alice 可以移除 "leetcod"含3個母音剩下 "e"Bob 無法移除含偶數母音的子字串
```
### 邊界清單
- [ ] 空陣列/空字串
- [ ] 單一元素 / 全相同
- [ ] 含負數/0/大數
- [ ] 去重
- [ ] 大資料壓力
- 全母音字串Alice 立即移除整個字串獲勝
- 無母音字串Alice 無法行動敗北
- 單一字符(母音/子音)
- 混合字串(含有母音和子音)
- 長字串壓力測試
## 複雜度分析
- 最壞:時間 O(?)、空間 O(?)
- 最壞:時間 O(n)、空間 O(1)
- 最佳:時間 O(1)(首字符即為母音)、空間 O(1)
## 相關題目 / Follow-up
-
- LeetCode 345: Reverse Vowels of a String
- LeetCode 1456: Maximum Number of Vowels in a Substring of Given Length
- LeetCode 2062: Count Vowel Substrings of a String
## 學習筆記
- 今天學到: