String-Matching
LeetCode 796: Rotate String
·2 mins
LeetCode
Easy
String
String-Matching
LeetCode 796 note: goal is a rotation of s exactly when the lengths match and goal occurs in s + s
LeetCode 572: Subtree of Another Tree
·2 mins
LeetCode
Easy
Tree
Depth-First-Search
String-Matching
Binary-Tree
LeetCode 572 note: for every node of root, check whether its subtree equals subRoot; recurse with isSubtree, not by comparing only the children
LeetCode 459: Repeated Substring Pattern
·1 min
LeetCode
Easy
String
String-Matching
Z-Algorithm
Knuth-Morris-Pratt-Algorithm
LeetCode 459 note: s is a repetition of a substring exactly when s occurs in s + s with its first and last characters removed
LeetCode 28: Find the Index of the First Occurrence in a String
·1 min
LeetCode
Easy
Two-Pointers
String
String-Matching
Z-Algorithm
LeetCode 28 note: try matching needle at every start, or use str.find; index raises when not found