string matching
string matching is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Find the Index of the First Occurrence in a String
Locate the first occurrence of a substring within a string using a two-pointer scanning strategy and invariant tracking …
Shortest Palindrome
The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…
Repeated Substring Pattern
Check if a string can be constructed by repeating a substring using string matching techniques.
Subtree of Another Tree
Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.
Repeated String Match
Find the minimum number of repetitions of string a to make string b a substring of the repeated string a.
Rotate String
Determine if one string can be rotated into another by repeatedly shifting characters, leveraging string matching techni…
Camelcase Matching
Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…
Longest Happy Prefix
Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.
Find All Good Strings
Find all good strings between two given strings without including a specified evil substring using dynamic programming.
String Matching in an Array
Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…
Check If a Word Occurs As a Prefix of Any Word in a Sentence
Determine the first word in a sentence where a given searchWord is a prefix using two-pointer scanning with string match…
Maximum Repeating Substring
Find the maximum number of times a given word repeats consecutively in a string using state transition dynamic programmi…
Form Array by Concatenating Subarrays of Another Array
Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…
Counting Words With a Given Prefix
Count how many words in a list start with a given prefix.
Sum of Scores of Built Strings
Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…
Match Substring After Replacement
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
Maximum Deletions on a String
Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …
String Transformation
Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.
Find Beautiful Indices in the Given Array I
Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.
Find Beautiful Indices in the Given Array II
Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.
Minimum Time to Revert Word to Initial State I
Determine the minimum seconds to revert a string to its original state using repeated prefix shifts of length k efficien…
Minimum Time to Revert Word to Initial State II
The problem asks to calculate the minimum time required to revert a string to its initial state using specific operation…
Number of Subarrays That Match a Pattern I
Count all subarrays in a given integer array that strictly follow a defined numeric pattern using rolling hash checks ef…
Number of Subarrays That Match a Pattern II
Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.
Count Prefix and Suffix Pairs I
Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.
Count Prefix and Suffix Pairs II
Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …
Minimum Number of Valid Strings to Form Target I
Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…
Minimum Number of Valid Strings to Form Target II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
Find the Occurrence of First Almost Equal Substring
Locate the first substring in s that is almost equal to pattern by allowing at most one character mismatch efficiently.
Substring Matching Pattern
Determine if a pattern containing a single wildcard can match any substring of a given string efficiently.
Shortest Matching Substring
Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…
Lexicographically Smallest Generated String
Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.
Count Cells in Overlapping Horizontal and Vertical Substrings
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…