I would like to share here the standard types of questions on string that I have faced till now and how to think of approching any string based question by categorizing them into 5 types.
Type I:
When it is required to validate the string or to find something in the string. In such questions, it is required to traverse the string like an array whilst validating or finding something.
Problems of this type:
Valid Parentheses
Valid Number
Compare Version Numbers
Type II
When you need to search a substring/another string. Most of such questions can be solved using pointer based approach. One/more pointer approach.
Problems of this type:
Longest Substring Without Repeating Characters
Implement strStr()
Substring with Concatenation of All Words
Valid Palindrome
Replace the Substring for Balanced String
Type III
When you need to find the smallest/largest/ conditional substring from the given string, sliding window approach is the way to go. An example of such question would be: find the longest substring without repeating character.
Problems on this type:
Minimum Window Substring
Maximum Number of Vowels in a Substring of Given Length
Longest Substring with At Most Two Distinct Characters (LC Premium)
Longest Substring with At Most K Distinct Characters (LC Premium)
Type IV
When the problem needs you to find all the permutations of a string, backtracking is the most common approach for such problems.
Problems on this type:
Split Array into Fibonacci Sequence
Regular Expression Matching
Letter Combinations of a Phone Number
Restore IP Addresses
Type V
Whenever the above approches do not fit, its most likely a question on Dynamic Programming. Try to identify the subproblem and solve using DP.
Problems on this type:
Longest Palindromic Substring
Longest Valid Parentheses
Wildcard Matching
Edit Distance