String, Subsequence & Substring

What is a Substring?

A substring is a contiguous part of a string, i.e., a string inside another string.

In general, for an string of size n, there are n*(n+1)/2 non-empty substrings. For example, Consider the string “Beginner”, There are 15 non-empty substrings. The subarrays are:

g, ge, gee, geek, Beginner,
e, ee, eek, eeks,
e, ek, eks,
k, ks,
ks

What is a Subsequence?

A subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing the order of the remaining elements.

More generally, we can say that for a sequence of size n, we can have ((2^n)-1) non-empty sub-sequences in total. For the same above example, there are 15 sub-sequences. They are:

g, e, e, k, s,
ge, ge, gk, gs, ee, ek, es, ek, es, ks,
gee, gek, ges, gek, ges, gks, eek, ees, eks, eks,
geek, gees, eeks,
Beginner

Easy Problems on Substring:

Medium Problems on Substring

Hard Problems on Substring

  1. Count of Distinct Substrings occurring consecutively in a given String
  2. Check if a String contains Anagrams of length K which does not contain the character X
  3. Check if a Palindromic String can be formed by concatenating Substrings of two given Strings
  4. Minimum size substring to be removed to make a given string palindromic
  5. Count ways to split a Binary String into three substrings having equal count of zeros
  6. Applications of String Matching Algorithms
  7. Minimum operations to transform given string to another by moving characters to front or end
  8. Count characters to be shifted from the start or end of a string to obtain another string
  9. Lexicographic rank of a string among all its substrings
  10. Count of substrings of a string containing another given string as a substring
  11. Count substrings of same length differing by a single character from two given strings
  12. Extract substrings between any pair of delimiters
  13. Longest substring where all the characters appear at least K times | Set 3
  14. Split a string into maximum number of unique substrings
  15. Find the last player to be able to flip a character in a Binary String
  16. Check if a string can be split into 3 substrings such that one of them is a substring of the other two
  17. Count ways to partition a number into increasing sequences of digits
  18. Maximum length of a substring required to be flipped repeatedly to make all characters of binary string equal to 0
  19. XOR of all substrings of a given Binary String
  20. Sub-strings of a string that are prefix of the same string

Easy Problems on Subsequences:

Medium Problems on Subsequences:

Hard Problems on Subsequences:

Contact Us