Z-Algorithm
LeetCode 459: Repeated Substring Pattern
·1 分鐘
LeetCode
Easy
String
String-Matching
Z-Algorithm
Knuth-Morris-Pratt-Algorithm
LeetCode 459 解題筆記:s 由某個子字串重複組成,等價於 s 出現在 (s + s) 去掉頭尾字元之後的字串裡
LeetCode 28: Find the Index of the First Occurrence in a String
·1 分鐘
LeetCode
Easy
Two-Pointers
String
String-Matching
Z-Algorithm
LeetCode 28 解題筆記:在每個起點比對 needle,或直接用 str.find;index 找不到會丟例外